Reputation: 19023
template<int, int>
struct T;
template<>
struct T<?, ?> {};
i want this to work
typedef T<1, 0> t;
and this to cause compile time error
typedef T<1, 2> t;
EDIT, i mean i want second parameter to be 0. and i can't use C++11 features.
Upvotes: 0
Views: 71
Reputation: 171117
Your quesiton is not too clear. Are you looking for this?
template <int, int>
struct T;
template<int x>
struct T<x, 0>
{
// Definition of the struct for the allowed case
};
Upvotes: 1
Reputation: 49231
You can use static_assert to assert the template arguments.
template<int A, int B>
struct T
{
static_assert(A > B, "Raised error because A is not bigger than B)";
}
Upvotes: 0