This is the mail archive of the gcc-bugs@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: Sometimes EGCS doesn't use an `operator foo()' for casting implicitly.


On Mar 20, 1999, "Martin v. Loewis" <martin@mira.isdn.cs.tu-berlin.de> wrote:

>> The attached file doesn't compile. Is this the intended behaviour, or a bug
>> in egcs?

> Without further analysis, this looks like a constness problem.

Yup

> class A { 
[snip]
>    operator pair<const string, A>() { return pair<const string,A>(s,*this); }
[snip]
> 	map<string,A> foo;
[snip]
> 	foo.insert(bar);          // Doesn't without

> I haven't tried figuring out whether this is conforming or not.

It is.  map<Key, T>::value_type is pair<const Key,T>, not pair<Key,T>,
so even if A provided an operator pair<string,A>, it would not be
implicitly used to convert one A to map::value_type because it would
involve two user-defined conversions: A::operator pair<string,A> and
pair<const string,A>'s templated constructor.

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Brazil
{oliva,Alexandre.Oliva}@dcc.unicamp.br  aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,egcs.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists



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