M
mathieu
Hello,
I am trying to express a very simple piece of code. I have:
#include <iostream>
enum A { a1, a2, a3, a4 };
enum B { b1, b2, b3, b4 };
template <int TA, int TB> struct Foo {
void foo() { std::cout << "general\n"; }
};
Now I want to say : only allow TB=b1 when TA=a1:
template<> struct Foo<a1,b1> {
void foo() { std::cout << "duplicated\n"; }
};
// mark everything else illegal:
template<int TB> struct Foo<a1, TB>;
This is working for me. The problem is that I need to duplicate the
code for Foo<a1,b1> when I simply want to use the general
implementation. Is there a way to say:
template <> struct Foo <a1,b1> : public Foo<a1,b1> ?
Or is there another way to achieve a compilation error for Foo <a1, `b!
=b1`>
Thanks
-Mathieu
I am trying to express a very simple piece of code. I have:
#include <iostream>
enum A { a1, a2, a3, a4 };
enum B { b1, b2, b3, b4 };
template <int TA, int TB> struct Foo {
void foo() { std::cout << "general\n"; }
};
Now I want to say : only allow TB=b1 when TA=a1:
template<> struct Foo<a1,b1> {
void foo() { std::cout << "duplicated\n"; }
};
// mark everything else illegal:
template<int TB> struct Foo<a1, TB>;
This is working for me. The problem is that I need to duplicate the
code for Foo<a1,b1> when I simply want to use the general
implementation. Is there a way to say:
template <> struct Foo <a1,b1> : public Foo<a1,b1> ?
Or is there another way to achieve a compilation error for Foo <a1, `b!
=b1`>
Thanks
-Mathieu