Home | Libraries | People | FAQ | More |
The requirements on the Backend
template argument to number
are split up into sections: compulsory and optional.
Compulsory requirements have no default implementation in the library, therefore if the feature they implement is to be supported at all, then they must be implemented by the backend.
Optional requirements have default implementations that are called if the backend doesn't provide its own. Typically the backend will implement these to improve performance.
In the following tables, type B is the Backend
template argument to number
,
b
and b2
are a variables of type B, pb
is a variable of type B*, cb
,
cb2
and cb3
are constant variables of type const
B
, rb
is a variable of type B&&
,
a
and a2
are variables of Arithmetic type, s
is a variable of type const char*
, ui
is a variable of type unsigned
, bb
is a variable of type bool
,
pa
is a variable of type
pointer-to-arithmetic-type, exp
is a variable of type B::exp_type
, pexp
is a variable of type B::exp_type*
,
i
is a variable of type
int
, pi
pointer to a variable of type int
,
B2 is another type that meets these requirements, b2 is a variable of type
B2, ss
is variable of type
std::streamsize
and ff
is a variable of type std::ios_base::fmtflags
.
Table 1.8. Compulsory Requirements on the Backend type.
Expression |
Return Type |
Comments |
Throws |
---|---|---|---|
|
|
A list of signed integral types that can be assigned to type B.
The types shall be listed in order of size, smallest first, and
shall terminate in the type that is |
|
|
|
A list of unsigned integral types that can be assigned to type
B. The types shall be listed in order of size, smallest first,
and shall terminate in the type that is |
|
|
|
A list of floating-point types that can be assigned to type B.The
types shall be listed in order of size, smallest first, and shall
terminate in type |
|
|
A signed integral type. |
The type of the exponent of type B. This type is required only for floating-point types. |
|
|
Default constructor. |
|
|
|
Copy Constructor. |
|
|
|
|
Assignment operator. |
|
|
|
Assignment from an Arithmetic type. The type of |
|
|
|
Assignment from a string. |
Throws a |
|
|
Swaps the contents of its arguments. |
|
|
|
Returns the string representation of |
|
|
|
Negates |
|
|
|
Compares |
|
|
|
Compares |
|
|
|
Adds |
|
|
|
Subtracts |
|
|
|
Multiplies |
|
|
|
Divides |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes the ones-complement of |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Converts |
|
|
|
Stores values in |
|
|
|
Stores a value in |
|
|
|
Stores values in |
|
|
|
Stores a value in |
|
|
|
Stores the floor of |
|
|
|
Stores the ceiling of |
|
|
|
Stores the square root of |
|
|
|
|
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets the real part of |
|
|
|
Sets the imaginary part of |
|
Table 1.9. Optional Requirements on the Backend Type
Expression |
Returns |
Comments |
Throws |
---|---|---|---|
Construct and assign: |
|||
|
|
Move constructor. Afterwards variable |
|
|
|
Move-assign. Afterwards variable |
|
|
|
Direct construction from an arithmetic type. The type of |
|
|
|
Copy constructor from a different back-end type. When not provided,
a generic interconversion routine is used. This constructor may
be |
|
|
|
Assignment operator from a different back-end type. When not provided, a generic interconversion routine is used. |
|
|
|
Assigns to |
|
|
|
Assigns to |
|
Comparisons: |
|||
|
|
Returns |
|
|
|
Returns |
|
|
|
Returns |
|
|
|
Returns |
|
|
|
Returns |
|
|
|
Returns |
|
|
|
Returns |
|
|
|
Returns |
|
|
|
Returns |
|
|
|
Returns |
|
|
|
Returns a value < zero if |
|
Basic arithmetic: |
|||
|
|
Adds |
|
|
|
Add |
|
|
|
Add |
|
|
|
Add |
|
|
|
Subtracts |
|
|
|
Subtracts |
|
|
|
Subtracts |
|
|
|
Subtracts |
|
|
|
Multiplies |
|
|
|
Multiplies |
|
|
|
Multiplies |
|
|
|
Multiplies |
|
|
|
Multiplies |
|
|
|
Multiplies |
|
|
|
Multiplies |
|
|
|
Multiplies |
|
|
|
Multiplies |
|
|
|
Multiplies |
|
|
|
Multiplies |
|
|
|
Multiplies |
|
|
|
Divides |
|
|
|
Divides |
|
|
|
Divides |
|
|
|
Divides |
|
|
void |
Increments the value of |
|
|
void |
Decrements the value of |
|
Integer specific operations: |
|||
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Computes |
|
|
|
Sets |
|
|
|
Returns the result of |
|
|
|
Returns the index of the least significant bit that is set. Only
required when |
|
|
|
Returns the index of the most significant bit that is set. Only
required when |
|
|
|
Returns true if |
|
|
|
Sets the bit at index |
|
|
|
Unsets the bit at index |
|
|
|
Flips the bit at index |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
Sign manipulation: |
|||
|
|
Set |
|
|
|
Set |
|
floating-point functions: |
|||
|
|
Returns one of the same values returned by |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Performs the equivalent operation to |
|
|
|
Scales value |
|
|
|
Calls |
|
|
|
Returns the exponent e of value |
|
|
|
Sets |
|
|
|
Default version converts a to type B and calls the overload above. |
|
|
|
Default version converts a to type B and calls the overload above. |
|
|
|
Default version calls eval_remquo with a dummy final argument. |
|
|
|
Default version calls eval_remquo with a dummy final argument. |
|
|
|
Default version calls eval_remquo with a dummy final argument. |
|
|
|
Default version sets |
|
|
|
Default version sets |
|
|
|
Default version sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
Sets |
|
|
|
As above. |
|
|
|
As above. |
|
|
|
Sets |
|
|
|
Calls |
|
|
|
Calls |
|
|
|
Sets |
|
hashing: |
|||
|
|
Returns a hash value for the argument that is suitable for use
with |
When the tables above place no throws requirements on
an operation, then it is up to each type modelling this concept to decide
when or whether throwing an exception is desirable. However, thrown exceptions
should always either be the type, or inherit from the type std::runtime_error
.
For example, a floating-point type might choose to throw std::overflow_error
whenever the result of an operation would be infinite, and std::underflow_error
whenever it would round to zero.
Note | |
---|---|
The non-member functions are all named with an "eval_" prefix to avoid conflicts with template classes of the same name - in point of fact this naming convention shouldn't be necessary, but rather works around some compiler bugs. |
Some of the C99 math functions do not have eval_
functions but must be overloaded directly: these functions are either trivial
or are forwarded to the Boost.Math implementations by default. The full list
of these functions is:
int sign (const number-or-expression-template-type&); int signbit (const number-or-expression-template-type&); number changesign (const number-or-expression-template-type&); number copysign (const number-or-expression-template-type&, const number-or-expression-template-type&); number asinh (const number-or-expression-template-type&); number acosh (const number-or-expression-template-type&); number atanh (const number-or-expression-template-type&); number cbrt (const number-or-expression-template-type&); number erf (const number-or-expression-template-type&); number erfc (const number-or-expression-template-type&); number expm1 (const number-or-expression-template-type&); number log1p (const number-or-expression-template-type&); number tgamma (const number-or-expression-template-type&); number lgamma (const number-or-expression-template-type&); long lrint (const number-or-expression-template-type&); long long llrint (const number-or-expression-template-type&); number nextafter (const number-or-expression-template-type&, const number-or-expression-template-type&); number nexttoward (const number-or-expression-template-type&, const number-or-expression-template-type&);