From -8367296928398200760
X-Google-Thread: 7894ca11fe,f5fa8c2235f87223
X-Google-Attributes: gid7894ca11fe,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.alt.net!frodo.cs.rpi.edu!not-for-mail
From: =3D?ISO-8859-1?Q?Daniel_Kr=3DFCgler?=3D <daniel.kruegler@googlemail.c=.om>
Newsgroups: comp.std.c++
Subject: Re: Trivial copy/move operations
Date: Thu,  8 Apr 2010 00:23:32 CST
Organization: http://groups.google.com
Lines: 69
Sender: cppmods@cs.rpi.edu
Approved: austern@google.com
Message-ID: <40e66b13-1602-4ca0-a28a-a76602d3649c@30g2000yqi.googlegroups.com>
References: <hotgch$cut$1@news.albasani.net>
NNTP-Posting-Host: netlab.cs.rpi.edu
Content-Type: text/plain; charset=ISO-8859-1
To: (Usenet)
Return-Path: <cppmods@ruralroute.cs.rpi.edu>
X-Original-Date: Wed, 7 Apr 2010 14:29:30 -0700 (PDT)
X-Submission-Address: std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.e=
	du>
Xref: g2news2.google.com comp.std.c++:2394

On 1 Apr., 02:00, Scott Meyers <NeverR...@aristeia.com> wrote:
> N3053 (about implicitly-generated move functions) says "Unions have
implicit
> deleted moves if a members has a non-trivial moves.  This rule is the sam=
e
> as for copy, and means that a user-defined union copy will not shadow a
> move."
>
> Can somebody please summarize for me what it means for a move or copy
> operation to be trivial?

I'm not sure that I understand this question properly. Are you asking
for the conditions/criteria that must be satisfied for a move or copy
function to be considered as trivial or are you asking for a summary
of all special rules that require such a trivial operation?

Without any guidance I reply to the first question:

1) For a trivial copy/move constructor ([class.copy]/13) or assignment
operator (/27) the requirements are that the c'tor is not user-
provided
nor deleted, that no virtual functions nor virtual base classes
exists, and
that all non-static data member and base class operation that will be
used for this copy/move are also trivial. It is note-worthy to
mention,
what a user-provided special member function is (I assume that the
term "deleted function" is sufficiently clear): It means that the
function
is user-declared and not explicitly defaulted on its first
declaration, e.g.

struct S {
 S(const S&) = default; // not user-provided
 S(S&) = delete; // explicitly deleted, therefore user-provided
};

It is also note-worthy to mention that a special member
function may be deleted without any explicit user-declaration.
For example the core language requires that the copy/move
assignment operator is deleted, if the class type has a
non-static data member of reference type.

2) Finally the standard distinguishes a "trivially copyable" type.
This is more than a type with trivial copy and trivial move
operations (and a trivial destructor as well), specifically there
must be *no* non-trivial copy and move operations, e.g. the type

struct Funny {
 Funny(const Funny&) = default;
 Funny(Funny&) = delete;
};

is *not* trivially copyable, because the second copy constructor
is not trivial.

HTH & Greetings from Bremen,

Daniel Kr=FCgler


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use
mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu>
]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



