我有一个类模板,我想写如下:
template </*what to put here?*/ T>
Class Bar {};
我想强制T只能是一个来自限定范围枚举的值。我使用了here提供的is_scoped_enum
类型检查,但是我能想到的最好的方法是将Bar
更改为如下形式:
template <typename T>
concept ScopeEnum = is_scoped_enum<T>::value;
template<ScopeEnum SE, SE se>
class Bar {};
如何实现它,使Bar
保持预期状态?
1条答案
按热度按时间oknwwptz1#
使用泛型非型别参数,并限制其宣告