I look at the standard paragraph 5.16, trying to understand what is happening. Consider a type Mdefined as
struct M {
M();
M(const M&);
M(M&&);
};
If I have a ternary expression pred ? E1 : E2where the type E1is equal const M&and the type E2is equal M&&, does 5.16 point 3 bullet 1 apply?
- If E2 is an lvalue: E1 can be converted to E2, if E1 can be implicitly converted (clause 4), enter "lvalue value for T2", subject to the limitation that the link must be linked directly (8.5.3) to the conversion lvalue.
I think this is not the case because implicit conversion to const M&requires Ma member function operator const M&(). However, I'm not sure, because it can be implicitly converted to const M, can a link be implicitly added?
If it is implicitly convertible, then M&&contact directly const M&? I went through the procedure described in 8.5.3 and I think paragraph 5 is where this case falls, so it is directly linked, but I'm not sure.
- If the initializer expression [..] has a class type (ie T2 is a class type), where T1 does not refer to T2 and can be implicitly converted to an xvalue value, the prvalue class or the lvalue function of type "cv3 T3", where " cv1 T1 "is link compatible with" cv3 T3 "