
AMDG cp now wrote:
The type_traits library gives me somewhat erroneous answers when dealing with pairs of pairs.
The following code produces the errors below, but interestingly, the BOOST_ASSERT actually succeeds. It seems is_convertible thinks a pair<pair<int, int>, int> is convertible to a plain old pair<int, int>, but the compiler (and this coder) takes a different view...
It's impossible to make it work in the general case. boost::is_convertible only checks whether there is a non-explicit constructor. To make the check work, we would need to somehow instantiate the constructor and detect whether compiling it succeeded of not. There is no way to do this in C++. Not possible: template<class T, class U> struct is_convertible_impl { static_try { U u = T(); typedef true_type type; } catch(compilation_error&) { typedef false_type type; } } In Christ, Steven Watanabe