Search code examples
c++templatesstlenable-if

What is the difference between std::enable_if and std::enable_if_t?


C++-14 introduced std::enable_if_t.

What is the difference between it and std::enable_if? Are there any advantages or differences in using std::enable_if_t?


Solution

  • std::enable_if_t is a type alias of the inner ::type of std::enable_if, it's syntactic sugar so you don't have to write

    typename std::enable_if</* */>::type