how do you whitelist template specializations?

How about setting the template argument to auto in both allowed_type and set?

template<auto value> struct allowed_type;

template<> struct allowed_type<Definitions::kField0> {
    using type = Field0Values;
};

template<auto maskValue>
constexpr void set(typename allowed_type<maskValue>::type) {}

Alternatively, if you prefer to keep allowed_type as is, you can also only change set:

template<auto maskValue>
constexpr void set(typename allowed_type<decltype(maskValue), maskValue>::type value) {}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top