Other operators

The function call operator provides function semantics for any object.

# Declarations

LR operator?:(bool, L, R);
P operator?:(bool, P, P);

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
CWG 446C++98it was unspecified whether a temporary is created for anlvalue-to-rvalue conversion on the conditional operatoralways creates a temporary ifthe operator returns a class rvalue
CWG 462C++98if the second operand of a comma operator is a temporary,it was unspecified whether its lifetime will be extended whenthe result of the comma expression is bound to a referencethe result of the comma expressionis the temporary in this case(hence its lifetime is extended)
CWG 587C++98when the second and third operands of a conditionaloperator are lvalues of the same type except forcv-qualification, the result was an lvalue if theseoperands have class types or an rvalue otherwisethe result is alwaysan lvalue in this case
CWG 1029C++98the type of a destructor call was unspecifiedspecified as void
CWG 1550C++98parenthesized throw expressions were not allowed inconditional expressions if other operand is non-voidaccepted
CWG 1560C++98void operand of conditional operators causedgratuitous lvalue-to-rvalue conversion on theother operand, always resulting in rvaluea conditional expressionwith a void can be lvalue
CWG 1642C++98the expression function in a function callexpression could be a function pointer lvaluenot allowed
CWG 1805C++98when determining the target type for the implicit conversionsequence, the way to convert Y to Z was unclearmade clear
CWG 1895C++98C++11unclear if deleted (C++11) or inaccessible (C++98)conversion function prevents conversion inconditional expressions, and conversions from baseclass to derived class prvalue were not consideredhandled likeoverload resolution
CWG 1932C++98same-type bit-fields were missing in conditional expressionshandled by underlying types
CWG 2226C++11when determining the target type of the otheroperand of a conditional operator, reference couldnot bind to an xvalue if that operand is an lvalueallowed
CWG 2283C++17the type completeness requirement for function calloperator was accidently removed by P0135R1restored the requirement
CWG 2321C++98when determining the target type of the other operandof a conditional operator, a derived class type couldnot be converted to a less cv-qualified base class typeallowed to convert to the baseclass type with the cv-qualificationfrom the derived class operand
CWG 2715C++98the initialization and destruction of eachparameter would occur within the context ofthe calling function, which might not exist[1]occurs within the context ofthe enclosing full-expression
CWG 2850C++98the destruction order of parameters was unclearmade clear
CWG 2865C++98if TX and TY are the same class type and TX ismore cv-qualified than TY, an implicit conversionsequence could still be formed from a prvalue Yno conversion sequencewill be formed in this case
CWG 2906C++98lvalue-to-rvalue conversions were unconditionally appliedin the rvalue result case for the conditional operatoronly applied in some cases

# See also