From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Niall Douglas" To: gcc@gcc.gnu.org Subject: Proposed C++ extension Date: Fri, 30 Aug 2002 16:32:00 -0000 Message-id: <3D701B78.8275.2A4BC906@localhost> X-SW-Source: 2002-08/msg01981.html Firstly, I'll apologise for not diving deep and producing a patch for g++. Last time I tried, I got very very lost ... My suggestion is adding support for temporary object copy constructors - these differ from normal copy constructors in that when the object is being created by the compiler rather than the user, the temporary object copy constructor is called instead. Why? Because C++ doesn't support multithreading very well. I have a number of implicitly shared classes for which I had to disable implicit sharing because of the potential of data corruption as it's impossible to synchronise all users of the implicit data without running through a mutex each time. Unfortunately disabling implicit sharing creates performance problems in something like a string class. If we had a special copy constructor for temporary objects, we could do ptr copies for the temporary objects and the real copy constructor for the final object. Obviously, optimisation can decide when user created local objects are unnecessary, and hence optimise them into temporary land. Anyway, if you were to add this, I'd stick the appropriate code into my implicitly shared-disabled classes. So would others I'm sure. String work would become much quicker. The other suggestion is a precall and postcall handler whereby in every call to an object, the compiler wraps the call with the precall and postcall code. Again, it's use is for porting old code to become multithreading aware - but I can envisage other useful uses as well. Anyway, those are my experiences from learning C++. I'm well into year three of learning it, but I'm still nowhere close to done! Cheers, Niall Douglas