This is the mail archive of the gcc-help@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]

Re: vector<MyTemplate<MyClass>> not possible?


>>>>> "FK" == Evert, F K van <F.K.vanEvert@plant.wag-ur.nl> writes:

    FK> When I put instances of a template-derived class in a STL
    FK> vector, g++ gives me the following error message
    FK> (Cygwin/g++3.2 as well as Suse8.0/g++2.95.3):

    FK> /usr/include/c++/3.2/bits/stl_construct.h:78: passing `const
    FK> SmartPtr<CX>' as `this' argument of `SmartPtr<T>::operator
    FK> T*() [with T = CX]' discards qualifiers

    FK> operator T*() { return m_pI ;}

should be: operator T*() const { return m_pI; }

Generally, it's a good idea to declare all member functions `const'
which don't change the state of their class instance.

-- 
Claudio Bley                                                        _ 
                                             ASCII ribbon campaign ( )
ICQ# 83197241                                 - against HTML email  X 
http://www.cs.uni-magdeburg.de/~bley/                     & vCards / \


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