[constrained_value] default initialization

I couldn't find mention of what is the initial value of bounded_int<int, 123, 456>::type some_var; I assume it follows the rules for an int? The Simple constrained objects examples says the following is legal: even_int a; What about: odd_int b; Thanks, Jeff

Hi Jeff,
I couldn't find mention of what is the initial value of
bounded_int<int, 123, 456>::type some_var;
I assume it follows the rules for an int?
Default construction always causes the underlying value to be value-initialised, so it'll be 0. Since 0 is not within the allowed range, the error policy will be invoked throwing an exception.
The Simple constrained objects examples says the following is legal:
even_int a;
What about:
odd_int b;
Same as above -- the underlying value will be 0 and the error policy will be invoked. Best regards, Robert
participants (2)
-
Jeff Flinn
-
Robert Kawulak