You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
N3055 distinguished xvalues from prvalues in typeid and ternary conditional operators, which changed their behaviors in some code that were well-formed in both C++98 and C++11.
More expressions were made evaluated in typeid (demo). Such expressions are xvalues of polymorphic class types that were already well-formed in C++98.
#include<cstdio>
#include<typeinfo>intmain() {
structB {
B() {}
virtual~B() { std::puts("C++11"); }
};
structC { B b; };
typeid(C().b); // unevaluated in C++98, evaluated in C++11
}
Less copies were made in the conditional operator (demo) if the second and the third operands were xvalues (that were well-formed in C++98) and the result was also an xvalue since C++11.
#include<cstdio>intmain() {
structB {
B() {}
B(const B&) { std::puts("C++98"); }
};
structD : B {};
structBB { B b; };
structDD { D d; };
true ? BB().b : DD().d; // additional copy in C++98, no copy or move in C++11
}
Perhaps we should list the behavior changes in [diff.cpp03.expr].
Suggested resolution:
The text was updated successfully, but these errors were encountered:
jensmaurer
changed the title
[diff.cpp03.expr] List behavioral changes of typeid and conditional operators in C++11
CWG2887 [diff.cpp03.expr] List behavioral changes of typeid and conditional operators in C++11
Apr 29, 2024
Full name of submitter (unless configured in github; will be published with the issue): Jiang An
Reference (section label): [diff.cpp03.expr]
Link to reflector thread (if any):
Issue description:
From editorial issue cplusplus/draft#6861.
N3055 distinguished xvalues from prvalues in
typeid
and ternary conditional operators, which changed their behaviors in some code that were well-formed in both C++98 and C++11.typeid
(demo). Such expressions are xvalues of polymorphic class types that were already well-formed in C++98.Perhaps we should list the behavior changes in [diff.cpp03.expr].
Suggested resolution:
The text was updated successfully, but these errors were encountered: