convertible concept

This is an extension of the Assignable concept for two different classes. The concept describes the construction or assignment of an object of type X from an object of type Y. If boost::is_same<X,Y>, then X is a model of Assignable.

The convertible concept is going to be used all over. It does not imply that conversions are always performed explicitly. It may just be a condition to allow an algorithm for two types. Whether the conversion happens or not depends on the implementation of the algorithm. For example, x+=y, does not imply y is first converted to an object of type X. The operation +=() for X may have a specialization for objects of type Y.

Description

Refinement of

Associated types

Notation

YThe type that is to be converted
XThe type that is converted to
xObject of type X
yObject of type Y

Definitions

Valid expressions

NameExpressionType requirementsReturn type
ConstructorX(y)Y is convertible to XX
Copy constructorX x(y)Y is convertible to XX
X x=yY is convertible to XX
Assignmentx=yX&

Expression semantics

NameExpressionPreconditionSemanticsPostcondition
ConstructorX(y)
Copy constructorX x(y)x is a copy of the conversion of y
X x=y
Assignmentx=yx is a copy of the conversion of y

Complexity guarantees

Invariants

Models

Notes