C++ 概念: CopyConstructible

来自cppreference.com

指定的类型的一个实例可以复制构造(复制).
Original:
Specifies that an instance of the type can be copy-constructed (copied).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
这个概念意味着MoveConstructible.
Original:
This concept implies MoveConstructible.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 要求

该类型必须实现以下功能:1
Original:
The type must implement the following functions:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Type::Type

Type::Type( Type& other );

Type::Type( const Type& other );
Type::Type( volatile Type& other );

Type::Type( const volatile Type& other );
(的变种之一就足够了)

拷贝构造函数: constructs an instance of a type with the contents of other. The internal state of other is not modified.

The following expressions must have the specified effects:

表达
Original:
Expression
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Effects
Type a = v;
a是相当于vrvType是一个实例。 v必须保持不变.
Original:
a is equivalent to v, where rv is an instance of Type. v must be unchanged.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Type(v);
Type是一个实例vv,相当于一个临时对象类型Typev必须保持不变.
Original:
a temporary object of type Type is equivalent to v, where v is an instance of Type. v must be unchanged.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 另请参阅

一类的检查,如果有拷贝构造函数
Original:
checks if a type has a copy constructor
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(类模板) [edit]