
pfultz2 wrote
Another way accomplishing this is to pass in an identity function: ... Then you can call it like this:
template< typename T > void assign ( T& x, T const& y ) { x = y;
static_if<boost::has_equal_to<T>::value>([](auto f) { assert(f(x) == f(y)); std::cout << "asserted for: " << typeid(T).name() << std::endl; }) .else_([] (auto) { std::cout << "cannot assert for: " << typeid(T).name() << std::endl; }); }
The identity function will make non-dependent types dependent, so this will compile.
Clever! However, IMO the `auto f` would look somewhat arbitrary to users (I'd have to explain it "magically" comes from within the implementation so you don't have to the bind...). So I'd probably stick with the bind because even if more verbose it's workings are more obvious to the users. Thank you for the suggestion. --Lorenzo -- View this message in context: http://boost.2283326.n4.nabble.com/static-if-Is-there-interest-in-a-static-i... Sent from the Boost - Dev mailing list archive at Nabble.com.