I tried to specialize the class template with another, as in the example below, and I noticed that this compiles and runs (at least on ideone, namely: gcc 4.3.4), whether the commented line is commented out or not.
#include <iostream>
template <typename F>
struct foo{
typedef F value_type;
};
template <typename G>
struct bar{};
//template<> <- works if commented out or not
template <typename F>
struct bar<foo<F> >
{
typename foo<F>::value_type val;
};
int main(void)
{
typedef foo<int> F;
typedef bar<F> B;
B b;
b.val = 10;
std::cout << b.val << std::endl;
return 0;
};
So my question is: is this really optional? I got the impression that a line is required for such specialization template<>..
source
share