Šimon Tóth’s Post

View profile for Šimon Tóth

C++ Educational Content Creator | 20 years of Software Engineering experience distilled into digestible daily posts

The conditional operator, also known as the ternary operator, is essentially an if statement in the form of an expression. The operator is sequenced. The left side, with all its side effects, is evaluated first, followed by one of the right-side operands (depending on the boolean value of the first operand). An important aspect of the conditional operator is that, as an expression, it must have a well-defined type. If the two right-side operands do not align on a type, conversions may be applied to arrive at a compatible common type. Before C++14 permitted compound expressions in constexpr functions, the ternary operator was the only way to inject logic into a constant-evaluated expression. Compiler Explorer link: https://lnkd.in/eyeYsd66 #cpp #cplusplus #coding #programming #dailybiteofcpp

  • text

Love the ternary operator ♥️

Like
Reply

To view or add a comment, sign in

Explore content categories