17

Here's an excerpt from the documentation of std::is_copy_constructible (1) and std::is_trivially_copy_constructible (2) on cppreference.com:

1) Checks whether a type is CopyConstructible, i.e. has an accessible explicit or implicit copy constructor. If the requirement is met, a member constant value equal true is provided, otherwise value is false.

2) Same as (1), but the copy constructor expression does not call any operation that is not trivial.

So what is considered a trivial operation here?

vitaut
  • 49,672
  • 25
  • 199
  • 336
  • 2
    [This](http://stackoverflow.com/questions/4178175/what-are-aggregates-and-pods-and-how-why-are-they-special) may help – Andy Prowl Mar 04 '13 at 23:25

1 Answers1

17

This quote from my previous answer explains it:

A copy/move constructor for class X is trivial if it is not user-provided and if

— class X has no virtual functions (10.3) and no virtual base classes (10.1), and

— the constructor selected to copy/move each direct base class subobject is trivial, and

— for each non-static data member of X that is of class type (or array thereof), the constructor selected to copy/move that member is trivial;

otherwise the copy/move constructor is non-trivial.

Basically this means that a copy or move constructor is trivial if it is not user-provided, the class has nothing virtual in it, and this property holds recursively for all the members of the class and for the base class.

Eric
  • 6,364
  • 1
  • 32
  • 49
R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510