I have a template struct with a nested template struct.
template <int F>
struct foo
{
template <int B>
struct bar {
static constexpr int f = F;
static constexpr int b = B;
};
};
I want to create a trait like
template <class>
struct is_foo_bar : std::false_type { };
template <int F, int B>
struct is_foo_bar< foo<F>::bar<B> > : std::true_type { };
static_assert(is_foo_bar< foo<1>::bar<2> >::value);
This gives an error:
type/value mismatch at argument 1 in template parameter list for ‘template<class> struct is_foo_bar’<br>
struct is_foo_bar<foo<F>::bar<B>> : std::true_type { };
If I take bar
out like
template <int F, int B>
struct foo_bar {
static constexpr int f = F;
static constexpr int b = B;
};
template <int F>
struct foo
{
template <int B>
using bar = foo_bar<F, B>;
};
template <class>
struct is_foo_bar : std::false_type { };
template <int F, int B>
struct is_foo_bar< foo_bar<F, B> > : std::true_type { };
static_assert(is_foo_bar< foo<1>::bar<2> >::value);
... it works. But this is not the way I want it to be. What I'm missing in code where bar
declaration is in foo
?
Aucun commentaire:
Enregistrer un commentaire