Problem with basic usage of std::enable_if

后端 未结 1 1951
南笙
南笙 2021-01-22 19:12

I\'m trying to make a simple template function that given some parameters, it outputs them with a space in between. Some of those can be elements of an enum, and in that case I

1条回答
  •  广开言路
    2021-01-22 19:54

    Default template arguments are not part of the function definition. Use a dummy parameter instead, so that the second argument has a different type:

    template::value, int> = 0>
    constexpr std::ostream& debug(const T& a) {
      std::cerr << (int)(a);
      return std::cerr;
    }
    
    template::value, int> = 0>
    constexpr std::ostream& debug(const T& a) {
      std::cerr << a;
      return std::cerr;
    }
    

    0 讨论(0)
提交回复
热议问题