lundi 30 novembre 2015

Conversion from std::pair

Here's an example that works on C++03 (-std=c++03) but fails on GCC and VS2015 for C++11 (-std=c++11, /Qstd=c++11)

#include <utility>

class B {
public:
   B(float);
};

class A {
public:
   A(B);
};

std::pair<int, A> a(std::make_pair(1, 2.0));

I have no idea why this would be invalid.. as far as I can see, the A members are direct-initialized by float as described in http://ift.tt/1Ijd3FZ . Is there an SFINAE test for implicit convertibility? As far as I can see, on cppreference it doesn't mention anything like that.

Aucun commentaire:

Enregistrer un commentaire