This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ Parser problem or I need glasses - template pointer to memberparameters



The lines in question are:


i_1->A::TFUNC_A<w_a,w_b>( m_b1 );

i_1->TFUNC_A<w_a,w_b>( m_b1 ); // compiler trubbell

without the A:: it seems like it fails to parse.

Time for a bug report ?

Apparently MSVC++ 7.0 and Borland compiles it fine confirmed by Rob Williscroft on news:comp.lang.c++
MSVC++ 6.0sp5 dumps an internal compiler error.


On the code below GCC 3.2.1 gives the following message:
g++ tt2.cpp -o tt2
tt2.cpp: In member function `void Zoo::B::TFUNC_B(Zoo::A*) [with
Zoo::A*Zoo::A::*w_a = &Zoo::A::m_mem1, Zoo::A*Zoo::B::*w_b =
&Zoo::B::m_b1]':
tt2.cpp:68: instantiated from here
tt2.cpp:54: invalid use of member (did you forget the `&' ?)
tt2.cpp:54: comparison between distinct pointer types `Zoo::A*Zoo::B::*' and `
Zoo::A*' lacks a cast
make: *** [tt2] Error 1




class Zoo
{

public:

class B;
class A
{


public:


A * m_mem1; A * m_mem2;

       template <
           A * A::*    w_a,
           A * B::*    w_b
       >
       void TFUNC_A( A * i_1 )
       {
           i_1->*w_a = i_1;
       }

typedef void ( A::* F_TA )( A * i_1 );

};

   class B
   {

public:

       A           * m_b1;
       A           * m_b2;

typedef void ( B::* F_TB )( A * i_1 );

template <
A * A::* w_a,
A * B::* w_b
>
void TFUNC_B( A * i_1 )
{
static const A::F_TA gg = ( & A::TFUNC_A<w_a,w_b> );
( i_1->*gg )( m_b1 );


           i_1->A::TFUNC_A<w_a,w_b>( m_b1 );
           i_1->TFUNC_A<w_a,w_b>( m_b1 ); // compiler trubbel
       }

void Fooey( A * i_1 )
{
// static A * A::* const l_mem1 = &A::m_mem1;
// static A * B::* const l_b1 = &B::m_b1;
// this->TFUNC_B< l_mem1, l_b1 >( i_1 );
// static const F_TB gg = &B::TFUNC_B< l_mem1, l_b1 >;


// static const F_TB gg = &B::TFUNC_B< (&A::m_mem1), (&B::m_b1) >;
// (this->*gg)( i_1 );
this->TFUNC_B< &A::m_mem1, &B::m_b1 >( i_1 );
}
};



};



int main() { Zoo::A a[1]; Zoo::B b[1];

b->Fooey( a );

   return 0;
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]