Steven Watanabe wrote:
AMDG
Tobias Schwinger
writes: dan marsden wrote:
Why is the fall through behaviour to throw an exception? I too tripped over this one, yesterday.
<snip>
The other option is an assertion. Is that any better?
I think the "default default behavior" should be to use the default constructor. This approach works nice with Any, Variant and Optional.
Or should a void return type be a special case?
If 'Default's result type is 'void' although something else is expected, we should assert it never actually returns at runtime (note that it is possible to detect the result type with an overloaded comma operator and without requiring 'Default' to work with 'result_of' -- might also be faster). If assertions are disabled the behavior should be unspecified in that case. <snip>
Of course there are no pointers to templates, so using a function pointer for anything but the default is pretty pointless. So is trying to handle varying result types -- maybe the result type should be passed in with another template parameter?
I'd rather leave it as result_of
::type.
Actually 'result_of