[aspectc-user] Problems with Templates

Stefan Marr aspectc at stefan-marr.de
Mon Jun 1 01:47:24 CEST 2009


Hello,

have here some problems with the following template code:

template<class T>
class VMPointer {
public:
    template<class U>
    VMPointer<T>(VMPointer<U>& o) {
        //index.index = o.index.index;
    };

    template<class U>   // here ac++ gets into trouble
    VMPointer<T>(const VMPointer<U>& o) {
        //index.index = o.index.index;
    };

    //allows to assign smart pointers of the same type
    inline VMPointer<T>& operator =(VMPointer<T> ptr);

};

template<class T>
VMPointer<T>& VMPointer<T>::operator=(VMPointer<T> ptr)
{
    if(&ptr == this) return *this;
    return *this;
};



The code compiles fine with g++, but ag++ seems always to stumble over  
the second occurrence of a function definition with an additional  
template parameter (here U).

This directly influences also the implementation of the operator =  
function.
I guess, this is somehow related, because without the functions with U  
ag++ is able to compile it.

VMPointer.h:17: error: invalid member declaration near token `template'
VMPointer.h:33: error: `VMPointer::operator =' already defined

Best regards
Stefan

-- 
Stefan Marr
Programming Technology Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://prog.vub.ac.be/~smarr
Phone: +32 2 629 3956
Fax:   +32 2 629 3525

-- 
Stefan Marr
Programming Technology Lab
Vrije Universiteit Brussel
Pleinlaan 2 / B-1050 Brussels / Belgium
http://prog.vub.ac.be/~smarr
Phone: +32 2 629 3956
Fax:   +32 2 629 3525




More information about the aspectc-user mailing list