E
er
Hi,
Is there a way to define A such that if B is defined like this
struct tag1{};
struct tag2{};
struct B : A<tag1, int>, A<tag2, double>{};
then
typedef B::F<tag1>::type v1_ // v1_ == int;
typedef B::F<tag2>::type v2_; // v2_ == double
By analogy, the above is feasible for a member function, say f,
template<typename Tag, typename T> struct A{
T f(Tag){ return T(); }
};
struct B : A<tag1, int>, A<tag2, double>
{
typedef A<tag1, int> a1_; using a1_::f;
typedef A<tag2, double> a2_; using a2_::f;
};
int main () {
B b;
b.f( tag1() );
b.f( tag2() );
return 0;
}
Thanks!
Is there a way to define A such that if B is defined like this
struct tag1{};
struct tag2{};
struct B : A<tag1, int>, A<tag2, double>{};
then
typedef B::F<tag1>::type v1_ // v1_ == int;
typedef B::F<tag2>::type v2_; // v2_ == double
By analogy, the above is feasible for a member function, say f,
template<typename Tag, typename T> struct A{
T f(Tag){ return T(); }
};
struct B : A<tag1, int>, A<tag2, double>
{
typedef A<tag1, int> a1_; using a1_::f;
typedef A<tag2, double> a2_; using a2_::f;
};
int main () {
B b;
b.f( tag1() );
b.f( tag2() );
return 0;
}
Thanks!