Silencing GCC warnings when using an "Uncopyable" class
Posted
by Kazade
on Stack Overflow
See other posts from Stack Overflow
or by Kazade
Published on 2008-12-27T10:15:28Z
Indexed on
2010/05/15
18:54 UTC
Read the original article
Hit count: 249
c++
|effective-c++
I have several classes that I don't want to be copyable, some of these classes have pointer data members. To make these classes uncopyable I privately inherit the following class template:
template <class T>
class Uncopyable
{
protected:
Uncopyable() {}
virtual ~Uncopyable() {}
private:
Uncopyable(const Uncopyable &);
T & operator=(const T&);
};
Which I used like so:
class Entity : private Uncopyable<Entity> { }
This works fine, however when I compile with -Weffc++ I still get the following warning:
class Entity has pointer data members
but does not override Entity(const Entity&)
or operator=(const Entity&)
Why is it still giving me this warning?
© Stack Overflow or respective owner