default-value

Easily select default usings for project namespaces and subamespaces

Is there an easy way in Visual Studio to assign default usings when i make a new file in a certain (sub)namespace in my project? ...

When returning a pointer, what to return if it's not found? C++

I'm not sure what to return as a default? myDrugs is a private vector<Drug*> container Drug* DrugDealer::getFirstDrugInSack(DrugType drugtobuy) { for (int i = 0; i < myDrugs.size(); i++) { if (myDrugs[i]->getType() == drugtobuy) return myDrugs[i]; } return 0; // is this right? } So I would call it like: D...

Is it possible to define a block with default arguments in Ruby?

This question deals with optional arguments passed to a Ruby block. I'm wondering if it's also possible to define arguments with default values, and what the syntax for that would be. At first glance, it appears that the answer is "no": def call_it &block block.call end call_it do |x = "foo"| p "Called the block with value #{x}" e...

"error: too few arguments to function"

I have a C program called opencv2.0 function : cvSaveImage( out_img_name, img); Compiler gcc reports that too few arguments to function cvSaveImage The prototype of cvSaveImage in highgui.h is CVAPI(int) cvSaveImage( const char* filename, const CvArr* image, const int* params CV_DEFAULT(0) ) After I change my call to be ...

setting default datacolumn values, good practice?

Is is good pratice to have the db set the default value of some columns when a new row is created or should the application set all values? Im not sure of the reasons for or against, but in non-null columns, it makes life easier. ...

Partially defaulting template arguments using typedefs?

I am trying to do something like this: template <typename T,bool Strong=true> class Pointer {...}; template <typename T> typedef Pointer<T,false> WeakPointer; But this is a compile error ("a typedef template is illegal" VC). I am trying to avoid doing this using inheritance, beacuse that's more unnecessary work (rewriting constructo...

How do I test a generic type variable for equality with Default(T) in Delphi?

I'm trying to write a generic cached property accessor like the following but am getting a compiler error when trying to check whether the storage variable already contains a value: function TMyClass.GetProp<T>(var ADataValue: T; const ARetriever: TFunc<T>): T; begin if ADataValue = Default(T) then // <-- compiler error on this line ...

What is the element value in an uninitialized vector?

If I create a vector like vector<myClass> v(10); what is the default value of each element? Also, what if it is a vector<myUnion> v(10) ? ...

Is there a way to set the default values for sfWidgetFormFilterDate widget?

I have an auto generated BaseBlahBlahBlahFilter.class file in my /lib/filter/base/ folder. It contain the following line for 'data' type field : 'date' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)), When the form loads it shows me empty va...

C++ pass pointer by reference and assign default value

hi! I would like to pass a pointer by reference to a function, such that i can actually change the address the passed pointer is pointing to and i'd like to assign this argument a default value. something like this: in the declaration void myFunc(SomeType* &var=NULL); and the definition: void MyClass::myFunc(SomeType* &var){ i...

Can Core Data content be edited directly?

I've been using Core Data for about a week now, and really loving it, but one minor issue is that setting default values requires going through and setting up a temp interface to load the data, which I then do away with once I have the data seeded. Is there any way to edit values in a table, like how you can use phpMyAdmin to manipulate...

What is the reason for not allowing in C++ a default value for a variable to be a non-static method or member of a class ?

I wanted to know why the default value for a variable for a method of a class, cannot be a non-static method or member of the same class. Is there a reason for that ? Could not the compiler provide to the method the position in the class of the non-static default value ? I tried to google quickly for an answer but I could not come up w...

Default value for generic data structure

I would like to write a SparseVector[T] class where T can be a double, an int or a boolean. The class will not be backed by an array (because I want a sparse data structure) but I have seen that when I build an empty array of an AnyVal type, the elements are initialized to the default value. For instance: scala> new Array[Int](10) re...

Unexpected Scala default values behavior

Why do the default values here behave differently when assigned explicitly to a val, versus printed directly? package blevins.example class SimpleWrap[T] { var t: T = _ def get = t } object App extends Application { val swb = new SimpleWrap[Boolean] val b = swb.get println("b: " + b) // b: false println("swb.get: " + swb....

Setting a default Apache RewriteRule entry

I want to set a 'default' rewrite rule to catch anything that didn't match the previous rewrite entries. I've tried this: RewriteRule ^(.*)/?$ index.php?url=$1 [L] But the output returned is: url = index.php Ideally what I want is to attach all the GET values to 'url' so they will be saved to my web log. Anyone have any suggestions...

Display XSD-defined default value of attribute using XSL

I thought this ought to be simple to find, yet after some searching I found this might be nice to define clearly. In my XSD I've defined an enum, derived from string. In a complex type I've defined and attribute that refers to this enum, with a default value. In my XSL I wish to display the default value of this attribute for elements ...

Default argument in a function [C++]

Hi, I tried to do something like this: int& g(int& number = 0) { //maybe do something with number return number; } but it doesn't work. It has to be passed by reference. Thank you for any help. P.S. I think that "Related Questions" appearing once you type Title is a good idea, but I also think that they should be displayed only i...

Left join not pulling through nulls where expected.

I have a query that looks something like this (I've changed the table names): select @user_id , isnull(ur.rule_value, isnull(manr.rule_value, def.rule_value)) [rule_value] , isnull(urt.name, isnull(manrt.name, def.name)) [rule_type] from (select @user_id [user_id] , rule.rule_value , rule_type.name fr...

default value for user defined class in c#

I see some code will return default value, so i am wondering for a user defined class, how will the compiler define its default value? ...

How to make computed column not nullable?

So far I've been using ISNULL(dbo.fn_GetPrice(ItemId), 0) to make it not nullable (rather call it default-valued, but whatever). Is this the right way? ...