Opened 11 years ago
Closed 8 years ago
#6578 closed Feature Requests (fixed)
Update noncopyable for C++11
| Reported by: | Daryle Walker | Owned by: | viboes |
|---|---|---|---|
| Milestone: | Boost 1.58.0 | Component: | utility |
| Version: | Boost Development Trunk | Severity: | Optimization |
| Keywords: | noncopyable | Cc: |
Description
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").
Attachments (1)
Change History (7)
by , 11 years ago
| Attachment: | noncopyable_cpp11.git.2.diff added |
|---|
comment:1 by , 10 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:3 by , 10 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
comment:4 by , 9 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
Vicente,
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 by , 9 years ago
I have no access to gcc-4.5.3. Please could you move to the public section and see how it works?
comment:6 by , 8 years ago
| Milestone: | Boost 1.54.0 → Boost 1.58.0 |
|---|---|
| Resolution: | → fixed |
| Status: | reopened → closed |
It seems the new code fixes this issue.
class noncopyable
{
protected:
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
BOOST_CONSTEXPR noncopyable() = default;
~noncopyable() = default;
#else
noncopyable() {}
~noncopyable() {}
#endif
#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
noncopyable( const noncopyable& ) = delete;
noncopyable& operator=( const noncopyable& ) = delete;
#else
private: // emphasize the following members are private
noncopyable( const noncopyable& );
noncopyable& operator=( const noncopyable& );
#endif
};

Changes for updating noncopyable for Cxx11