templates, nesting and using problem

  • Thread starter Norman J. Goldstein
  • Start date
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top