At 2:12 AM -0500 2/22/09, Yang Zhang wrote:
Yang Zhang wrote:
Hi, I can't figure out how to properly use noncopyable. I'm always getting things like "has a non-virtual destructor" warnings.
Do you have a simple test case?
$ cat noncopyable.cc #include
using namespace boost; class C : noncopyable {}; int main() { return 0; } $ g++ -Wall -g3 -o noncopyable noncopyable.cc [...] -Weffc++ [...] cc1plus: warnings being treated as errors noncopyable.cc:3: error: base class âclass boost::noncopyable_::noncopyableâ has a non-virtual destructor
I understand that this shouldn't be a problem as noncopyable is not meant to be used directly as any variable's static type, but I do require enabling this warning.
The warning is due to the use of -Weffc++: Warn about violations of the following style guidelines from Scott Meyers' Effective C++ book: ... * Item 14: Make destructors virtual in base classes. ... This is a case where that admonition is wrong. (It is a style guideline after all, and not necessarily prescriptive.) You might be able to suppress this warning by using -Wno-nonvirtual-dtors, but that may suppress warnings that you would actually like to see. This is one of the reasons why we're not using -Weffc++ where I work. (I think I recall there being some boost libraries that run afoul of item 7 "Never overload &&, ||, or ,." too.)