#include <type_traits>
struct T2;
struct T1 {
T1(){}
T1(int){}
operator T2();
};
struct T2 {
operator int() { return 0; }
};
struct T3 {
operator int() { return 0; }
};
T1::operator T2() { return T2(); }
using namespace std;
using X = T1;
using Y = T2;
using Z = T3;
int main()
{
true?T2():T3(); // int
static_assert(std::is_same<std::common_type_t<T2,
T3>,
int>::value,
"Not int");
true?T1():(true?T2():T3()); // T1
static_assert(std::is_same<std::common_type_t<T1,
std::common_type_t<T2,
T3>>,
T1>::value,
"Not T1");
// -----------------------------------------
true?T1():T2(); // T2
static_assert(std::is_same<std::common_type_t<T1,
T2>,
T2>::value,
"Not T2");
true?(true?T1():T2()):T3(); // int
static_assert(std::is_same<std::common_type_t<std::common_type_t<T1,
T2>,
T3>,
int>::value,
"Not int");
// -----------------------------------------
static_assert( is_same<common_type_t< X, common_type_t<Y,Z> >,
common_type_t< common_type_t<X,Y>, Z > >::value,
"Don't match");
}
I2luY2x1ZGUgPHR5cGVfdHJhaXRzPgoKc3RydWN0IFQyOwpzdHJ1Y3QgVDEgewogICAgVDEoKXt9CiAgICBUMShpbnQpe30KICAgIG9wZXJhdG9yIFQyKCk7Cn07CnN0cnVjdCBUMiB7CiAgICBvcGVyYXRvciBpbnQoKSB7IHJldHVybiAwOyB9Cn07CnN0cnVjdCBUMyB7CiAgICBvcGVyYXRvciBpbnQoKSB7IHJldHVybiAwOyB9Cn07ClQxOjpvcGVyYXRvciBUMigpIHsgcmV0dXJuIFQyKCk7IH0KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnVzaW5nIFggPSBUMTsKdXNpbmcgWSA9IFQyOwp1c2luZyBaID0gVDM7CmludCBtYWluKCkKewoKICAgIHRydWU/VDIoKTpUMygpOyAvLyBpbnQKICAgIHN0YXRpY19hc3NlcnQoc3RkOjppc19zYW1lPHN0ZDo6Y29tbW9uX3R5cGVfdDxUMiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUMz4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQ+Ojp2YWx1ZSwKICAgICAgICAgICAgICAgICAgIk5vdCBpbnQiKTsKCiAgICB0cnVlP1QxKCk6KHRydWU/VDIoKTpUMygpKTsgLy8gVDEKICAgIHN0YXRpY19hc3NlcnQoc3RkOjppc19zYW1lPHN0ZDo6Y29tbW9uX3R5cGVfdDxUMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OmNvbW1vbl90eXBlX3Q8VDIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFQzPj4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUMT46OnZhbHVlLAogICAgICAgICAgICAgICAgICAiTm90IFQxIik7CgogICAgLy8gLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KCiAgICB0cnVlP1QxKCk6VDIoKTsgLy8gVDIKICAgIHN0YXRpY19hc3NlcnQoc3RkOjppc19zYW1lPHN0ZDo6Y29tbW9uX3R5cGVfdDxUMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUMj4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUMj46OnZhbHVlLAogICAgICAgICAgICAgICAgICAiTm90IFQyIik7CgogICAgdHJ1ZT8odHJ1ZT9UMSgpOlQyKCkpOlQzKCk7IC8vIGludAogICAgc3RhdGljX2Fzc2VydChzdGQ6OmlzX3NhbWU8c3RkOjpjb21tb25fdHlwZV90PHN0ZDo6Y29tbW9uX3R5cGVfdDxUMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVDI+LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFQzPiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludD46OnZhbHVlLAogICAgICAgICAgICAgICAgICAiTm90IGludCIpOwoKICAgIC8vIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCgogICAgc3RhdGljX2Fzc2VydCggaXNfc2FtZTxjb21tb25fdHlwZV90PCBYLCBjb21tb25fdHlwZV90PFksWj4gICAgPiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbW9uX3R5cGVfdDwgICAgY29tbW9uX3R5cGVfdDxYLFk+LCBaID4gPjo6dmFsdWUsCiAgICAgICAgICAgICAgICAgICAgIkRvbid0IG1hdGNoIik7Cn0=
prog.cpp: In function 'int main()':
prog.cpp:54:5: error: static assertion failed: Don't match
static_assert( is_same<common_type_t< X, common_type_t<Y,Z> >,
^