The Ring
concept represents Group
s that also form a Monoid
under a second binary operation that distributes over the first.
A Ring is an algebraic structure built on top of a Group
which requires a monoidal structure with respect to a second binary operation. This second binary operation must distribute over the first one. Specifically, a Ring
is a triple (S, +, *)
such that (S, +)
is a Group
, (S, *)
is a Monoid
and *
distributes over +
, i.e.
The second binary operation is often written *
with its identity written 1
, in reference to the Ring
of integers under multiplication. The method names used here refer to this exact ring.
one
and mult
satisfying the laws
For all objects x
, y
, z
of a Ring
R
, the following laws must be satisfied:
Monoid
, Group
A data type T
is arithmetic if std::is_arithmetic<T>::value
is true. For a nonboolean arithmetic data type T
, a model of Ring
is automatically defined by using the provided Group
model and setting
bool
is the same as for not providing Monoid and Group models.Let A
and B
be two Ring
s. A function f : A > B
is said to be a Ring morphism if it preserves the ring structure between A
and B
. Rigorously, for all objects x, y
of data type A
,
Because of the Ring
structure, it is easy to prove that the following will then also be satisfied:
which is to say that f
will then also be a Group
morphism. Functions with these properties interact nicely with Ring
s, which is why they are given such a special treatment.
Variables  
constexpr auto  boost::hana::mult 
Associative operation of a Ring . More...  
template<typename R >  
constexpr auto  boost::hana::one 
Identity of the Ring multiplication. More...  
constexpr auto  boost::hana::power 
Elevate a ring element to its n th power. More...  

constexpr 
#include <boost/hana/fwd/mult.hpp>
Associative operation of a Ring
.
x,y  Two Ring elements to combine with the Ring binary operation. 
The mult
method is "overloaded" to handle distinct data types with certain properties. Specifically, mult
is defined for distinct data types A
and B
such that
A
and B
share a common data type C
, as determined by the common
metafunctionA
, B
and C
are all Ring
s when taken individuallyto<C> : A > B
and to<C> : B > C
are Ring
embeddings, as determined by the is_embedding
metafunction.The definition of mult
for data types satisfying the above properties is obtained by setting

constexpr 
#include <boost/hana/fwd/one.hpp>
Identity of the Ring
multiplication.
R  The tag (must be a model of Ring ) of the returned identity. 

constexpr 
#include <boost/hana/fwd/power.hpp>
Elevate a ring element to its n
th power.
Specifically, power(x, n)
, is equivalent to multiplying x
with itself n
times using the Ring's multiplication. If the power is equal to zero
, the Ring's identity (one
) is returned.
x  A Ring element that is elevated to its n th power. 
n  A nonnegative IntegralConstant representing the power to which x is elevated. 
x
is used for tagdispatching.