mardi 1 septembre 2020

Use member type of template template parameter as a non-type parameter [duplicate]

Is there a way to use a member type of a template template parameter as a non-type parameter? What I want to achieve is that if I have a template class like this one:

template<size_t N>
struct A
{
    using BT = uint32_t;
};

Now, I want to use the BT (guaranteed to be integeral) type as a non-type parameter in another template. What I have tried so far:

template <size_t N, A<N>::BT Value> // error: ‘A::BT’ is not a type
struct B
{
    static constexpr A<N> val = Value;
};

template <size_t N, template<size_t> class T, T<N>::BT Val>  // error: ‘T<N>::BT’ is not a type
struct C
{
    static constexpr T<N> val = Value;
};

Aucun commentaire:

Enregistrer un commentaire