c++ default operators
Hi list I was told that gcc by default, for every class creates operator =, and probably something else. This makes binary file bit larger than it suppose to be. Is it true, and if so, why this is the case ? Can gcc simply not generate that operator? -- Vercetti
Re: c++ default operators
On Fri, Sep 23, 2005 at 07:09:21PM +0200, Tommy Vercetti wrote: I was told that gcc by default, for every class creates operator =, and probably something else. This makes binary file bit larger than it suppose to be. Is it true, and if so, why this is the case ? Can gcc simply not generate that operator? In the C++ language, we have the concept of the default assignment operator and the default copy constructor, which are created if needed by the compiler. But gcc won't create these if they aren't used. Another extra function people sometimes complain about is the two copies of the constructor: the in-charge version is for constructing an instance of the class, and the not-in-charge version is for initializing the base portion of a derived class. Getting rid of the not-in-charge version, for cases where it isn't needed, would require something like Java's final keyword.
Re: c++ default operators
Joe Buck wrote: Another extra function people sometimes complain about is the two copies of the constructor: the in-charge version is for constructing an instance of the class, and the not-in-charge version is for initializing the base portion of a derived class. Getting rid of the not-in-charge version, for cases where it isn't needed, would require something like Java's final keyword. Can't you get rid of the not-in-charge version by using -ffunction-sections and then linking with -Wl,--gc-sections (at least for an ELF/GNU binutils target)? David Daney