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]

Re: template problem with 971016


> I've encountered a problem with templates: if you try to insert() a a
> key-value pair<> into a multimap<>, the signature selection code won't
> treat a pair<k,v> as an acceptable match for the pair<const k,v> that
> it wants.

No, you've encountered a problem because you're using the wrong definition
of pair<>, one that you've gotten from SGI instead of using the EGCS
version (which is just the SGI version with the correct configuration
information -- you might be able to fix it by changing the SGI configuration
to say that member templates are supported).  Your code works fine when
you link against the provided headers.

SGI STL will only allow you to use pair<k,v> where pair<const k,v> is
desired if __STL_MEMBER_TEMPLATES is defined.  That's because it is
relying on the following templated constructor:

template <class T1, class T2>
struct pair {
	...
    template <class U1, class U2>
    pair(const pair<U1, U2>& p) : first(p.first), second(p.second) {}
};

As you can see, this allows any pair to be constructed from any other.

> BTW, should I do anything special to get egcs to work with
> libg++-2.7.2?  I get warnings from egcs about the new() and delete()
> declared in g++-include/new.h.

Why would you want to do this?  If you're hoping that this will allow you
to link egcs-generated code to 2.7.2-generated code, I'm afraid you're
going to have problems -- you'd need to turn off a number of things to
get the code to match.  If you need stuff in the old libg++, you're
better off starting with libg++-2.8.0b6, which you can find on
ftp.cygnus.com/pub/g++, though there may be a newer version.


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