Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class template quantity

boost::units::quantity — class declaration

Synopsis

// In header: <boost/units/quantity.hpp>

template<typename Unit, typename Y> 
class quantity {
public:
  // types
  typedef quantity< Unit, Y > this_type; 
  typedef Y                   value_type;
  typedef Unit                unit_type; 

  // private member functions
   BOOST_MPL_ASSERT_NOT(unspecified);

  // public member functions
  quantity();
  quantity(unspecified_null_pointer_constant_type);
  quantity(const this_type &);
  BOOST_CXX14_CONSTEXPR this_type & operator=(const this_type &);
  template<typename YY> 
    quantity(const quantity< Unit, YY > &, unspecified = 0);
  template<typename YY> 
    explicit quantity(const quantity< Unit, YY > &, unspecified = 0);
  template<typename YY> 
    BOOST_CXX14_CONSTEXPR this_type & operator=(const quantity< Unit, YY > &);
  template<typename Unit2, typename YY> 
    explicit quantity(const quantity< Unit2, YY > &, unspecified = 0);
  template<typename Unit2, typename YY> 
    quantity(const quantity< Unit2, YY > &, unspecified = 0);
  template<typename Unit2, typename YY> 
    BOOST_CXX14_CONSTEXPR this_type & operator=(const quantity< Unit2, YY > &);
  BOOST_CONSTEXPR const value_type & value() const;
  template<typename Unit2, typename YY> 
    BOOST_CXX14_CONSTEXPR this_type & 
    operator+=(const quantity< Unit2, YY > &);
  template<typename Unit2, typename YY> 
    BOOST_CXX14_CONSTEXPR this_type & 
    operator-=(const quantity< Unit2, YY > &);
  template<typename Unit2, typename YY> 
    BOOST_CXX14_CONSTEXPR this_type & 
    operator*=(const quantity< Unit2, YY > &);
  template<typename Unit2, typename YY> 
    BOOST_CXX14_CONSTEXPR this_type & 
    operator/=(const quantity< Unit2, YY > &);
  BOOST_CXX14_CONSTEXPR this_type & operator*=(const value_type &);
  BOOST_CXX14_CONSTEXPR this_type & operator/=(const value_type &);

  // public static functions
  static BOOST_CONSTEXPR this_type from_value(const value_type &);

  // protected member functions
  explicit quantity(const value_type &, int);
};

Description

quantity private member functions

  1.  BOOST_MPL_ASSERT_NOT(unspecified);

quantity public member functions

  1. quantity();
  2. quantity(unspecified_null_pointer_constant_type);
  3. quantity(const this_type & source);
  4. BOOST_CXX14_CONSTEXPR this_type & operator=(const this_type & source);
  5. template<typename YY> 
      quantity(const quantity< Unit, YY > & source, unspecified = 0);
    implicit conversion between value types is allowed if allowed for value types themselves
  6. template<typename YY> 
      explicit quantity(const quantity< Unit, YY > & source, unspecified = 0);
    implicit conversion between value types is not allowed if not allowed for value types themselves
  7. template<typename YY> 
      BOOST_CXX14_CONSTEXPR this_type & 
      operator=(const quantity< Unit, YY > & source);
    implicit assignment between value types is allowed if allowed for value types themselves
  8. template<typename Unit2, typename YY> 
      explicit quantity(const quantity< Unit2, YY > & source, unspecified = 0);
    explicit conversion between different unit systems is allowed if implicit conversion is disallowed
  9. template<typename Unit2, typename YY> 
      quantity(const quantity< Unit2, YY > & source, unspecified = 0);
    implicit conversion between different unit systems is allowed if each fundamental dimension is implicitly convertible
  10. template<typename Unit2, typename YY> 
      BOOST_CXX14_CONSTEXPR this_type & 
      operator=(const quantity< Unit2, YY > & source);
    implicit assignment between different unit systems is allowed if each fundamental dimension is implicitly convertible
  11. BOOST_CONSTEXPR 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

  12. template<typename Unit2, typename YY> 
      BOOST_CXX14_CONSTEXPR this_type & 
      operator+=(const quantity< Unit2, YY > & source);
    can subtract a quantity of the same type if subtract_typeof_helper<value_type,value_type>::type is convertible to value_type
  13. template<typename Unit2, typename YY> 
      BOOST_CXX14_CONSTEXPR this_type & 
      operator-=(const quantity< Unit2, YY > & source);
  14. template<typename Unit2, typename YY> 
      BOOST_CXX14_CONSTEXPR this_type & 
      operator*=(const quantity< Unit2, YY > & source);
  15. template<typename Unit2, typename YY> 
      BOOST_CXX14_CONSTEXPR this_type & 
      operator/=(const quantity< Unit2, YY > & source);
    can multiply a quantity by a scalar value_type if multiply_typeof_helper<value_type,value_type>::type is convertible to value_type
  16. BOOST_CXX14_CONSTEXPR this_type & operator*=(const value_type & source);
    can divide a quantity by a scalar value_type if divide_typeof_helper<value_type,value_type>::type is convertible to value_type
  17. BOOST_CXX14_CONSTEXPR this_type & operator/=(const value_type & source);

quantity public static functions

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

quantity protected member functions

  1. explicit quantity(const value_type & val, int);

PrevUpHomeNext