C++14 之前的模板元编程和条件运算符

Pre-C++14 template metaprogramming and conditional operator

来自cppreference.com

Such conditional operator was commonly used in C++11 constexpr programming prior to C++14.

std::string str = 2+2==4 ? "ok" : throw std::logic_error("2+2 != 4");

cppreference指的是什么?什么是 C++14 之前的习语以及为什么在 C++14 中该技术不再相关?

you could not have more than one statement, basically, in a constexpr function. In 你可以。

constexpr bool str(int x){
  return  2+2==x ? true : throw std::logic_error("2+2 != x");
}

对比

constexpr bool str(int x){
  if (2+2==x)
    return true;
  else
     throw std::logic_error("2+2 != x");
}