Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #463

Volatile copyable not trivially copyable?

From Al Grant<algrant@myrealbox.com>
Newsgroups comp.std.c++
Subject Volatile copyable not trivially copyable?
Date 2012-03-24 17:55 -0700
Organization http://groups.google.com
Message-ID <c86fa57d-ffdf-4b3e-bb5f-bd5f6eb0bb0e@q11g2000vbu.googlegroups.com> (permalink)

Show all headers | View raw


Given a POD struct type, say  struct S { int a; };
it was always the case that if you wanted to be able to
assign to a volatile S, you had to explicitly define a
volatile-qualified copy-assignment operator:
   operator=(S const&) volatile;
But this makes S "not trivially copyable".  And in C++11
that means you can't instantiate std::atomic<S>.

Have I missed something?  It seems strange that if I
want to wrap a primitive type in a class for abstraction
reasons (in an OS maybe) the class can either be
volatile-qualified and assigned freely, or used as the
basis for an atomic type, but not both.  After all, there's
no such restriction on primitive types.

As a constructive suggestion, would there be any
consequences if the standard were to permit defining
   operator=(S cv-qualifiers&) volatile = default;
and consider it a trivial copy assignment operator?


-- 
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextNext in thread | Find similar


Thread

Volatile copyable not trivially copyable? Al Grant<algrant@myrealbox.com> - 2012-03-24 17:55 -0700
  Re: Volatile copyable not trivially copyable? Daniel Krügler <daniel.kruegler@googlemail.com> - 2012-03-25 23:14 -0700

csiph-web