Re: [Boost-bugs] [Boost C++ Libraries] #8057: Add constexpr + noexcept for atomic

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8057: Add constexpr + noexcept for atomic
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-02-14 17:59:10


#8057: Add constexpr + noexcept for atomic
-------------------------------+--------------------------------------------
  Reporter: viboes | Owner: timblechmann
      Type: Feature Requests | Status: new
 Milestone: Boost 1.54.0 | Component: atomic
   Version: Boost 1.53.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+--------------------------------------------

Comment (by viboes):

 Hi,

 The following patch worked for me.


 {{{
 svn diff boost/atomic
 Index: boost/atomic/detail/base.hpp
 ===================================================================
 --- boost/atomic/detail/base.hpp (revision 82860)
 +++ boost/atomic/detail/base.hpp (working copy)
 @@ -143,7 +143,7 @@
      typedef T value_type;
      typedef lockpool::scoped_lock guard_type;
  public:
 - base_atomic(void) {}
 + BOOST_CONSTEXPR base_atomic(void) {}

      explicit base_atomic(const value_type & v)
      {
 @@ -230,8 +230,8 @@
      typedef T difference_type;
      typedef lockpool::scoped_lock guard_type;
  public:
 - explicit base_atomic(value_type v) : v_(v) {}
 - base_atomic(void) {}
 + explicit BOOST_CONSTEXPR base_atomic(value_type v) : v_(v) {}
 + BOOST_CONSTEXPR base_atomic(void) {}

      void
      store(value_type v, memory_order /*order*/ = memory_order_seq_cst)
 volatile
 Index: boost/atomic/atomic.hpp
 ===================================================================
 --- boost/atomic/atomic.hpp (revision 82860)
 +++ boost/atomic/atomic.hpp (working copy)
 @@ -88,8 +88,8 @@
      typedef T value_type;
      typedef atomics::detail::base_atomic<T, typename
 atomics::detail::classify<T>::type,
 atomics::detail::storage_size_of<T>::value, boost::is_signed<T>::value >
 super;
  public:
 - atomic(void) : super() {}
 - explicit atomic(const value_type & v) : super(v) {}
 + BOOST_CONSTEXPR atomic(void) : super() {}
 + explicit BOOST_CONSTEXPR atomic(const value_type & v) : super(v) {}

      atomic & operator=(value_type v) volatile
      {

 }}}


 But I suspect that we need to specialize boost::atomic<integral>.

 BTW, why the construtor needs a memcpy?

 {{{
     explicit base_atomic(const value_type & v)
     {
         memcpy(&v_, &v, sizeof(value_type));
     }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8057#comment:4>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:12 UTC