Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > [atomics.flag] ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 9419 of 9971
Post > Topic >>

[atomics.flag] About std::atomic_flag default ctor

by Alberto Ganesh Barbati <AlbertoBarbati@[EMAIL PROTECTED] > Mar 26, 2008 at 04:41 AM

Hi,

in the latest public draft (N2588 at the moment of writing) the default
ctor of class std::atomic_flag is defaulted and any instance of such
class must be initialized with

   atomic_flag guard = ATOMIC_FLAG_INIT;

where ATOMIC_FLAG_INIT is a suitably provided macro. While I do
understand the need for all this machinery, unless I'm much mistaken
that is exactly the same idiom that is used in boost to implement the
once_flag struct (http://boost.org/doc/html/boost/call_once.html).

However, when the thread library has been integrated in the draft,
std::once_flag was provided a constexpr default ctor and the need for
macro was removed (see [thread.once.onceflag]).

So I am wondering: is there something that prevents std::atomic_flag to
follow the same idiom used for std::once_flag, thereby removing the need
for ATOMIC_FLAG_INIT? If the answer is no, I propose the following
changes:

- In [atomics]/2: remove line

     #define ATOMIC_FLAG_INIT unspecified

- In [atomics.flag], change the declaration of the default ctor from:

     atomic_flag() = default;

   to

     constexpr atomic_flag();

- Ditto, remove line

     #define ATOMIC_FLAG_INIT unspecified

- In [atomics.flag]/3, replace:

     The atomic_flag type shall have standard layout. It shall have a
     trivial default constructor, a deleted copy constructor, a deleted
     copy assignment operator, and a trivial destructor.

   with:

     The atomic_flag type shall have standard layout and a trivial
     destructor.

   (there's no need to require that the copy ctor and assignment operator
   are deleted, as it is already clear and explicit from the class
   definition).

- Remove [atomics.flag]/4 entirely.

Just my 2 eurocent,

Ganesh


-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 1 Posts in Topic:
[atomics.flag] About std::atomic_flag default ctor
Alberto Ganesh Barbati &l  2008-03-26 04:41:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Sep 4 23:50:15 CDT 2008.