我正在尝试使用概念对某些模板方法进行显式特化,但它不是在 gcc 上编译的或 msvc , 但可以在 clang 上编译...谁是对的?
#include <type_traits>
template<typename T>
concept arithmetic = std::is_arithmetic_v<T> && !std::is_same_v<T, bool>;
template<typename T>
void foo(const T &value, int &result);
template<>
void foo(const arithmetic auto &value, int &result) {
}
最佳答案
正确的语法是
template<arithmetic T>
void foo(const T &value, int &result){}
或
void foo(const arithmetic auto &value, int &result){}
所以没有template<>
或 template<arithmetic T>
关于c++ - 明确的概念特化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69147302/