default-value

How do I set parameter default values that rely on other parameters?

只愿长相守 提交于 2019-12-01 02:11:58
The following code compiles and works as expected. #include <vector> void function(std::vector<int> vec, int size=1); int main(){ std::vector<int> vec = {1,2,3}; function(vec); } void function(std::vector<int> vec, int size){ //code.. return; } However, I would like the size parameter's default value to be deduced based on a previous parameter. So for example: void function(std::vector<int> vec, int size=vec.size()); But this however results in: error: local variable ‘vec’ may not appear in this context Which doesn't surprise me; I assume it needs to know the default value at compile time. So

Distinguish &optional argument with default value from no value

可紊 提交于 2019-12-01 01:40:30
问题 According to Functions on GigaMonkeys, Common Lisp supports optional positional parameters via &optional and the default value can be set arbitrarily. The default default value is nil . (defun function (mandatory-argument &optional optional-argument) ... ) and the default value can be set arbitrarily (defun function (mandatory-argument &optional (optional-argument "")) ....) Is there a way of distinguishing the cases where the optional parameter has the default value explicitly passed in vs

Linq To Sql: handle NewID()

余生长醉 提交于 2019-11-30 23:53:23
hey, im trying to add data to my sqlserver by using Linq To Sql, in the table, the data design to get NEWID() when new row is inserted, but the linq to sql ignore it and the cell in null, thanks! It sounds like you're expecting a guid value to be auto-generated for you right at the time of insert. It sounds like that column has a DEFAULT of NewID() . In your LINQ To SQL model, navigate to the table's property whose value is auto-generated. Right-click, Properties, and ensure the attribute Auto Generated Value is set to True. This will ensure the INSERT statement generated doesn't include a

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

我怕爱的太早我们不能终老 提交于 2019-11-30 20:53:46
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 ADataValue := ARetriever(); Result := ADataValue; end; The error I'm getting is "E2015 Operator not applicable to this operand type". Would I have to put a constraint on T to make this work? The help file says that Default() would accept anything except generic

ServiceThrottling default values?

让人想犯罪 __ 提交于 2019-11-30 19:25:55
Hi, According to this link the default values of WCF 4.0 is this : MaxConcurrentSessions: 16 * processorcount MaxConcurrentSessions: MaxConcurrentCalls + MaxConcurrentSessions 100 * processorcount MaxConcurrentSessions: 100 * processorcount I know, not that clear. When looking in the documentation at MSDN( WCF 4.0 ) it says this : maxConcurrentCalls : 16 maxConcurrentInstances : 26 maxConcurrentSessions : 10 If I however look at the WCF 4.5 some of the values is based on CPU like the first example maxConcurrentCalls : 16 times the processor count maxConcurrentInstances : The default is the sum

Default values for array arguments

余生颓废 提交于 2019-11-30 18:22:23
Just playing around a little with C++. What I really want to do is to be able to setup a function with default values defined for an array or pointer argument. To keep things simple, let's just use an array. Like so: void experimentA(char a[3] = {'a', 'b', 'c'}); The compiler (LLVM GCC 4.2 with GNU99) complains "Expected expression". That is quite obtuse, but I was told by colleagues that this is happening because the 'value' I'm trying to assign is statically allocated, whereas the variable I'm trying to assign it to ( a[3] ) is auto. But I'm not completely sure if that's the case, since I'm

Linq To Sql: handle NewID()

大憨熊 提交于 2019-11-30 18:11:06
问题 hey, im trying to add data to my sqlserver by using Linq To Sql, in the table, the data design to get NEWID() when new row is inserted, but the linq to sql ignore it and the cell in null, thanks! 回答1: It sounds like you're expecting a guid value to be auto-generated for you right at the time of insert. It sounds like that column has a DEFAULT of NewID() . In your LINQ To SQL model, navigate to the table's property whose value is auto-generated. Right-click, Properties, and ensure the

JSF 2 - hiding default values on <? extends Number>

懵懂的女人 提交于 2019-11-30 18:08:49
问题 is there a way to hide the default values of my number properties? I've got a int field and on my view the <h:inputText /> field shows a 0. In addition to this, if I leave this input empty I get a NullPointerException on this. Can I hide the default value and treat empty inputs as default value? I'm using mojarra 2.1.2 on Tomcat 7 回答1: The primitive int always defaults to 0 . You want to use Integer instead. E.g.: public class Entity { private Integer value; // ... } As to keeping it null

Get default value of an input using jQuery

∥☆過路亽.° 提交于 2019-11-30 17:16:38
$(".box_yazi2").each(function () { var default_value = this.value; $(this).css('color', '#555'); // this could be in the style sheet instead $(this).focus(function () { if (this.value == default_value) { this.value = ''; $(this).css('color', '#000'); } }); $(this).blur(function () { if (this.value == '') { $(this).css('color', '#555'); this.value = default_value; } }); }); This function of default value of input doesnt work in FF, but perfectly works in IE and ofcourse the input itself looks like this: <input type="text" class="box_yazi2" id="konu" name="konu" value="Boş" /> Andreas Niedermair

How to get the initialisation value for a Java Class reference

你离开我真会死。 提交于 2019-11-30 16:51:38
问题 I have a Class<?> reference for an arbitrary type. How to get that type's initialisation value? Is there some library method for this or do I have to roll my own, such as: Class<?> klass = ... Object init = (klass == boolean.class) ? false : (klass == byte.class) ? (byte) 0 ... : (Object) null; The use case is I have an arbitrary java.lang.reflect.Method reference, which I want to call using arbitrary parameters (for some testing), which may not be null in case the parameter is a primitive