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]

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


Hi,

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

-- 
Chris Butler
<chrisb@sandy.force9.co.uk>

#include <map>
#include <string>

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

private:
   string s;
};

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

	foo.insert((ent)bar);     // Works with cast
	foo.insert(bar);          // Doesn't without
}

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