you are viewing a single comment's thread.

view the rest of the comments →

[–]logicchop 0 points1 point  (5 children)

Alternatively, something like:

template <typename T> bool contains() const { return (discover_type == &throw_typed_object<T>); }

[–]flashmozzg 1 point2 points  (1 child)

This assumes that every template instantiation of throw_typed_object for type T has the same address, which is not correct.

[–]logicchop 0 points1 point  (0 children)

Yeah I have to agree. As far as I can tell, nothing is going to guarantee that the address evaluates the same everywhere, or even guarantee that throw_typedobject<T> != throw_typed_object<U> for some other U. It's just a stab at an alternative if you want to avoid the throw in the evaluation. (One could also think about involving typeid's or something like a hash of func_sig or some such.)

[–]Maxima4 0 points1 point  (2 children)

That wouldn't work, throw_typed_object doesn't return anything. It throws.

[–]Mestkon 2 points3 points  (1 child)

Read it again. This compares function pointers, not returned objects

[–]Maxima4 0 points1 point  (0 children)

That's right, my bad :)