Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y>

boost::units::quantity<BOOST_UNITS_DIMENSIONLESS_UNIT(System), Y>

Synopsis

// 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 &);
};

Description

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/destruct

  1. quantity& operator=(const this_type & source);
  2. 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
  3. 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 functions

  1.  quantity();
  2.  quantity(value_type val);
    construction from raw value_type is allowed
  3.  quantity(const this_type & source);
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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.

  9. operator value_type() const;
    implicit conversion to value_type is allowed
  10. 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

  11. 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
  12. 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
  13. 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
  14. this_type & operator/=(const value_type & val);

quantity public static functions

  1. static this_type from_value(const value_type & val);
    Construct quantity directly from value_type.

PrevUpHomeNext