N
Norman J. Goldstein
I want to pull a type out of a class, by employing
the "using" mechanism, but ran into a problem.
Here is the code:
/////////////////////////////
template< typename D >
struct PL
{};
template< template<typename> class Q >
struct G
{};
template< typename D, template<typename> class P >
struct S
{
template< typename D0 >
using S0 = S< D0, P >;
static G< S0 > g; // First type of g. <== Line 15
};
S< int, PL > s;
// Intention: S1 == S0
template< typename D >
using S1 = typename S< D, PL >::template S0<D>;
template<>
G< S1 > S1<int>::g; // Second type of g. <== Line 25
////////////////////////////////
gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC)
gives the following error messages:
templ4.cpp:25:18: error: conflicting declaration ‘G<S1> S<int, PL>::g’
templ4.cpp:15:18: error: ‘S<int, PL>::g’ has a previous declaration as
‘G<S<int, PL>::S0> S<int, PL>::g’
The bottom line from these messages is that the template types
S1 and S<int, PL>::S0
are different. But why are they not the same?
the "using" mechanism, but ran into a problem.
Here is the code:
/////////////////////////////
template< typename D >
struct PL
{};
template< template<typename> class Q >
struct G
{};
template< typename D, template<typename> class P >
struct S
{
template< typename D0 >
using S0 = S< D0, P >;
static G< S0 > g; // First type of g. <== Line 15
};
S< int, PL > s;
// Intention: S1 == S0
template< typename D >
using S1 = typename S< D, PL >::template S0<D>;
template<>
G< S1 > S1<int>::g; // Second type of g. <== Line 25
////////////////////////////////
gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC)
gives the following error messages:
templ4.cpp:25:18: error: conflicting declaration ‘G<S1> S<int, PL>::g’
templ4.cpp:15:18: error: ‘S<int, PL>::g’ has a previous declaration as
‘G<S<int, PL>::S0> S<int, PL>::g’
The bottom line from these messages is that the template types
S1 and S<int, PL>::S0
are different. But why are they not the same?