Ticket #6578 (closed Feature Requests: fixed)

Opened 5 years ago

Last modified 2 years ago

Update noncopyable for C++11

Reported by: dlwalker Owned by: viboes
Milestone: Boost 1.58.0 Component: utility
Version: Boost Development Trunk Severity: Optimization
Keywords: noncopyable Cc:


Here's a quick update to boost::noncopyable for C++11, which has added enough primitives to express the concept directly. I tried it out with a copy of GCC 4.6, and have included the patch (with "svn diff --git").


noncopyable_cpp11.git.2.diff Download (3.1 KB) - added by dlwalker 5 years ago.
Changes for updating noncopyable for Cxx11

Change History

Changed 5 years ago by dlwalker

Changes for updating noncopyable for Cxx11

comment:1 Changed 4 years ago by viboes

  • Owner changed from no-maintainer to viboes
  • Status changed from new to assigned

comment:2 Changed 4 years ago by viboes

  • Milestone changed from Boost 1.50.0 to Boost 1.54.0

Committed revision [83833].

comment:3 Changed 4 years ago by viboes

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [83869]) utility/noncopyable : fix #6578.

comment:4 Changed 3 years ago by ramey

  • Status changed from closed to reopened
  • Resolution fixed deleted


I'm having a problem with this patch. My gcc 4.53 compiler gives the error message:

"noncopayable:: declared with non-public access cannot be defaulted in the class body"

Which seems to make some sense to me. My copy of the standard (section 8.4.2) says "If it[the function] is explicitly defaulted on its first declaration, — it shall be public," As usual the standard text is somewhat convoluted, but that what it says to me. I'm not sure why the test passes. The macro name (BOOST_NO_DEFAULTED_FUNCTIONS used to condition this code has been marked as deprecated in favor of a new one (BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) i don't know if that might be related.

Robert Ramey

comment:5 Changed 3 years ago by viboes

I have no access to gcc-4.5.3. Please could you move to the public section and see how it works?

comment:6 Changed 2 years ago by viboes

  • Status changed from reopened to closed
  • Resolution set to fixed
  • Milestone changed from Boost 1.54.0 to Boost 1.58.0

It seems the new code fixes this issue.

  class noncopyable
      BOOST_CONSTEXPR noncopyable() = default;
      ~noncopyable() = default;
      noncopyable() {}
      ~noncopyable() {}
      noncopyable( const noncopyable& ) = delete;
      noncopyable& operator=( const noncopyable& ) = delete;
  private:  // emphasize the following members are private
      noncopyable( const noncopyable& );
      noncopyable& operator=( const noncopyable& );

Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.