[2] The reason this says 'x is a copy of y ', rather than 'x == y ', is that operator== is not necessarily defined: equality is not a requirement of Assignable. If the type X is EqualityComparable as well as Assignable, then a copy of x should compare equal to x.

See also

DefaultConstructible

Default Constructible

Category: utilities

Component type: concept

Description

A type is DefaultConstructible if it has a default constructor, that is, if it is possible to construct an object of that type without initializing the object to any particular value.

Notation

X A type that is a model of DefaultConstructible

x An object of type X

Valid expressions
Name Expression Return type
Default constructor X() X
Default constructor X x; [1]
Expression semantics
Name Expression
Default constructor X()
Default constructor X x;
Models

• int

• vector<double>

Notes

[1] The form X x = X() is not guaranteed to be a valid expression, because it uses a copy constructor. A type that is DefaultConstructible is not necessarily Assignable

See also

Assignable

Equality Comparable

Category: utilities

Component type: concept

Description

A type is EqualityComparable if objects of that type can be compared for equality using operator==, and if operator== is an equivalence relation.

Notation

X A type that is a model of EqualityComparable

x, y, z Object of type X

Valid expressions
Name Expression Return type
Equality x == y Convertible to bool
Inequality x != y Convertible to bool
Expression semantics
Name
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату