cp now wrote:
The type_traits library gives me somewhat erroneous answers when dealing with pairs of pairs.
The compiler appears to be attempting a piecewise conversion of the contents of the pair, hence the error about converting pair
to 'int' rather than an error about converting pair , int> to pair . Is there a method of converting that is_convertible has in mind when it returns true for the aforementioned conversion? I'm testing here for simple implicit conversion...
is_convertible does tell you about implicit convertibility, it answers the
question:
Does type "To" have a copy constructor that accepts a type "From"?
And indeed std::pair has such a constructor, so is_convertible answers true.
Unfortunately what no traits class can answer is the question:
Does this code compile?
And that's where this example fails: std::pair has a "catch all" constructor
that will accept any kind of pair as an argument, so that
is_convertible