Boost C++ Libraries: Ticket #11141: boost::noncopyable does not prevent adding copy constructor to derived class https://svn.boost.org/trac10/ticket/11141 <p> The documentation from boost::noncopyable is quite minimal. <a href="http://www.boost.org/doc/libs/1_55_0/libs/utility/utility.htm#Class_noncopyable">http://www.boost.org/doc/libs/1_55_0/libs/utility/utility.htm#Class_noncopyable</a> <a class="ext-link" href="http://stackoverflow.com/questions/7823990/what-are-the-advantages-of-boostnoncopyable"><span class="icon">​</span>http://stackoverflow.com/questions/7823990/what-are-the-advantages-of-boostnoncopyable</a> </p> <p> To my understanding the attached code shouldn't compile </p> <p> $ gcc --version gcc (Debian 4.9.2-10) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11141 Trac 1.4.3 Andreas Fenkart <afenkart@…> Wed, 25 Mar 2015 09:59:45 GMT attachment set https://svn.boost.org/trac10/ticket/11141 https://svn.boost.org/trac10/ticket/11141 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test_noncopyable.cpp</span> </li> </ul> <p> class deriving boost::noncopyable and declaring copy constructor </p> Ticket viboes Thu, 26 Mar 2015 07:26:44 GMT component changed; owner set https://svn.boost.org/trac10/ticket/11141#comment:1 https://svn.boost.org/trac10/ticket/11141#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">No-Maintainer</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">utility</span> </li> </ul> Ticket Marshall Clow Thu, 26 Mar 2015 15:24:55 GMT <link>https://svn.boost.org/trac10/ticket/11141#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11141#comment:2</guid> <description> <p> My opinion on this is "close as not a bug". </p> <p> We don't prevent people from acting maliciously. </p> <p> <code>noncopyable</code> makes the copy constructor and assignment operators private (and doesn't implement them), so if you call them you get a compile (or link) error. If you go and implement your own copy constructor in a class that is derived from <code>noncopyable</code>, then my belief is that you wanted to be able to copy those objects. </p> </description> <category>Ticket</category> </item> <item> <author>Andreas Fenkart <afenkart@…></author> <pubDate>Tue, 31 Mar 2015 08:09:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11141#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11141#comment:3</guid> <description> <p> Yup, seems I got the semantics wrong, boost::noncopyable is a macro, that spares some typing. I still have to ensure Foo contains no copy constructor, I hoped it would free me from checking that as well. </p> <p> I retire the question </p> </description> <category>Ticket</category> </item> <item> <author>Andreas Fenkart <afenkart@…></author> <pubDate>Tue, 31 Mar 2015 08:13:45 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/11141 https://svn.boost.org/trac10/ticket/11141 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test_noncopyable2.cpp</span> </li> </ul> <p> boost::noncopyable correctly working </p> Ticket Marshall Clow Wed, 01 Apr 2015 22:16:11 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11141#comment:4 https://svn.boost.org/trac10/ticket/11141#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> Not really a macro - but a class that you inherit from to get certain behavior. </p> <p> Because the behavior is inherited, you can override it if you choose. </p> Ticket