Sometimes EGCS doesn't use an `operator foo()' for casting implicitly.

Martin v. Loewis martin@mira.isdn.cs.tu-berlin.de
Sat Mar 20 16:03:00 GMT 1999


> 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. The
code below compiles.

#include <map>
#include <string>

class A { 
public:
   A(const string& a): s(a) { }
   operator pair<const string, A>() { return pair<const string,A>(s,*this); }

private:
   string s;
};

int main()
{
	map<string,A> foo;
	A bar("bar");

	foo.insert(bar);          // Doesn't without
}

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

Regards,
Martin


More information about the Gcc-bugs mailing list