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! ]


|