It is not faster. There is one difference when you can initialize a constant variable depending on some expression:
const int x = (a<b) ? b : a;
You can’t do the same with if-else
.
More Related Contents:
- Regarding time out in code
- How do I use the conditional (ternary) operator?
- Is < faster than
- What is the advantage of using forwarding references in range-based for loops?
- Does the C++ standard mandate poor performance for iostreams, or am I just dealing with a poor implementation?
- What is IACA and how do I use it?
- Performance of built-in types : char vs short vs int vs. float vs. double
- What’s your favorite profiling tool (for C++) [closed]
- How expensive is RTTI?
- Which is more efficient: Return a value vs. Pass by reference?
- How much is the overhead of smart pointers compared to normal pointers in C++?
- Using AVX CPU instructions: Poor performance without “/arch:AVX”
- Why does this delay-loop start to run faster after several iterations with no sleep?
- Conditional operator used in cout statement
- clock function in C++ with threads
- What is the fastest way to change a key of an element inside std::map
- Efficiency of the STL priority_queue
- Avoiding denormal values in C++
- Writing function definition in header files in C++
- Ternary operator is twice as slow as an if-else block?
- Performance hit from C++ style casts?
- shared_ptr: horrible speed
- Why is std::vector::operator[] 5 to 10 times faster than std::vector::at()?
- Simple for() loop benchmark takes the same time with any loop bound
- Why do I see 400x outlier timings when calling clock_gettime repeatedly?
- What is the modern, correct way to do type punning in C++?
- New (std::nothrow) vs. New within a try/catch block
- C++ most efficient way to convert string to int (faster than atoi)
- Why is this C++ wrapper class not being inlined away?
- should std::common_type use std::decay?