...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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 it's 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, 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
pointertoarithmetictype, 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 floatingpoint 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 onescomplement 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 





Table 1.9. Optional Requirements on the Backend Type
Expression 
Returns 
Comments 
Throws 

Construct and assign: 



Move constructor. Afterwards variable 



Moveassign. Afterwards variable 



Direct construction from an arithmetic type. The type of 



Copy constructor from a different backend type. When not provided,
a generic interconversion routine is used. This constructor may
be 



Assignment operator from a different backend 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 



Scales value 



Returns the exponent e of value 



Sets 
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 nonmember 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. 