...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y>
// In header: <boost/units/quantity.hpp> template<typename System, typename Y> class quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y> { public: // types typedef quantity< unit< dimensionless_type, System >, Y > this_type; typedef Y value_type; typedef System system_type; typedef dimensionless_type dimension_type; typedef unit< dimension_type, system_type > unit_type; // construct/copy/destruct quantity& operator=(const this_type &); template<typename YY> quantity& operator=(const quantity< unit< dimension_type, system_type >, YY > &); template<typename System2> quantity& operator=(const quantity< BOOST_UNITS_DIMENSIONLESS_UNIT(System2), Y > &); // public member functions quantity() ; quantity(value_type) ; quantity(const this_type &) ; template<typename YY> quantity(const quantity< unit< dimension_type, system_type >, YY > &, unspecified = 0) ; template<typename YY> quantity(const quantity< unit< dimension_type, system_type >, YY > &, unspecified = 0) ; template<typename System2, typename Y2> quantity(const quantity< unit< dimensionless_type, System2 >, Y2 > &, unspecified = 0, unspecified = 0, unspecified = 0) ; template<typename System2, typename Y2> quantity(const quantity< unit< dimensionless_type, System2 >, Y2 > &, unspecified = 0, unspecified = 0, unspecified = 0) ; template<typename System2, typename Y2> quantity(const quantity< unit< dimensionless_type, System2 >, Y2 > &, unspecified = 0) ; operator value_type() const; const value_type & value() const; this_type & operator+=(const this_type &) ; this_type & operator-=(const this_type &) ; this_type & operator*=(const value_type &) ; this_type & operator/=(const value_type &) ; // public static functions static this_type from_value(const value_type &) ; };
Specialization for dimensionless quantities. Implicit conversions between unit systems are allowed because all dimensionless quantities are equivalent. Implicit construction and assignment from and conversion to value_type
is also allowed.
quantity
public
construct/copy/destructquantity& operator=(const this_type & source);
template<typename YY> quantity& operator=(const quantity< unit< dimension_type, system_type >, YY > & source);implicit assignment between value types is allowed if allowed for value types themselves
template<typename System2> quantity& operator=(const quantity< BOOST_UNITS_DIMENSIONLESS_UNIT(System2), Y > & source);implicit assignment between different unit systems is allowed
quantity
public member functionsquantity() ;
quantity(value_type val) ;construction from raw
value_type
is allowed quantity(const this_type & source) ;
template<typename YY> quantity(const quantity< unit< dimension_type, system_type >, YY > & source, unspecified = 0) ;implicit conversion between value types is allowed if allowed for value types themselves
template<typename YY> quantity(const quantity< unit< dimension_type, system_type >, YY > & source, unspecified = 0) ;implicit conversion between value types is not allowed if not allowed for value types themselves
template<typename System2, typename Y2> quantity(const quantity< unit< dimensionless_type, System2 >, Y2 > & source, unspecified = 0, unspecified = 0, unspecified = 0) ;implicit conversion between different unit systems is allowed
template<typename System2, typename Y2> quantity(const quantity< unit< dimensionless_type, System2 >, Y2 > & source, unspecified = 0, unspecified = 0, unspecified = 0) ;implicit conversion between different unit systems is allowed
template<typename System2, typename Y2> quantity(const quantity< unit< dimensionless_type, System2 >, Y2 > & source, unspecified = 0) ;
conversion between different unit systems is explicit when the units are not equivalent.
operator value_type() const;implicit conversion to
value_type
is allowed const value_type & value() const;constant accessor to value
can add a quantity of the same type if add_typeof_helper<value_type,value_type>::type is convertible to value_type
this_type & operator+=(const this_type & source) ;can subtract a quantity of the same type if subtract_typeof_helper<value_type,value_type>::type is convertible to value_type
this_type & operator-=(const this_type & source) ;can multiply a quantity by a scalar value_type if multiply_typeof_helper<value_type,value_type>::type is convertible to value_type
this_type & operator*=(const value_type & val) ;can divide a quantity by a scalar value_type if divide_typeof_helper<value_type,value_type>::type is convertible to value_type
this_type & operator/=(const value_type & val) ;