This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Feature request for vtable emitter
- To: egcs-bugs at cygnus dot com
- Subject: Re: Feature request for vtable emitter
- From: Jason Gunthorpe <jgg at gpu dot srv dot ualberta dot ca>
- Date: Wed, 10 Dec 1997 11:55:00 -0700 (MST)
- Reply-To: egcs-bugs at cygnus dot com
On Wed, 10 Dec 1997, Klaus-Georg Adams wrote:
> >>>>> "Jason" == Jason Gunthorpe <jgg@gpu.srv.ualberta.ca> writes:
>
> [...]
>
> >> No, because non-virtual member functions don't have to be
> >> defined.
>
> Jason> Erm, but who on earth would actually do that? :>
>
> I do this all the time to prevent generation of implicit default and
> copy ctors and assignment operators if I don't want them:
>
> class myClass {
> public:
> myClass(int) {}
> void whatever() {}
> private:
> // The following are never defined, they give link errors
> // if you try to use them.
> myClass();
> myClass( const myClass& );
> myClass& operator=( const myClass& );
> };
My understanding is that the better solution is simply:
private:
myClass() {};
myClass(const myClass &) {};
myClass &operator =(const myClass &) {};
This will only allow functions within the class to call these functions
(they are private). Of course if you actually want to prevent use within
the class that is different. The usual need I have seen for this is to
prevent -users- from using the functions, the class author can be carefull
enough to advoid them.
If stuff like this is the only reason to limit the definition of the class
base member to virtual function I would really like to see it made an
option, those of us who don't use this technique can safely enable it and
speed up the compiler and shrink down the .o files.
Thanks,
Jason