我发现 typename Enable = void
定义在 ProtoBuf 中,
template<typename T, typename Enable = void>
struct RefTypeTraits;
但是,我找不到 Enable
用于此 header file ,这让我很困惑。 typename Enable = void
在模板中是什么意思?
最佳答案
是允许SFINAE具有模板特化,例如:
template <typename T>
struct RefTypeTraits<T, std::enable_if_t<some_condition<T>::value>>
{
// ... specialization for T which respects condition
};
从 C++20 开始,我们可以特化 concepts以避免这个需要额外的模板参数。
关于c++ - 'typename Enable = void' 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34459640/