'C++ compile time ternary conditional
Please, help me to figure out syntax of compile time ternary conditional in C++:
#include <iostream>
#include <type_traits>
int main(void)
{
//const auto y = constexpr(std::is_null_pointer_v<decltype(nullptr)>) ? 777 : 888.8;
const auto y = constexpr(std::is_null_pointer_v<decltype(nullptr)> ? 777 : 888.8);
std::cout<<y<<std::endl;
}
Both of the options above give me error: expected primary-expression before ‘constexpr’ (gcc-11.2.0; compiled with g++ -std=c++17).
Thank you very much for your help!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
