Ticket #7573: operators.diff

File operators.diff, 1.3 KB (added by nathan.crookston@…, 10 years ago)

Add operator++, --, % to quantity

  • msw/include/boost/units/quantity.hpp

    diff --git a/msw/include/boost/units/quantity.hpp b/msw/include/boost/units/quantity.hpp
    index 4fe916d..b405829 100644
    a b class quantity  
    280280        ///< can divide a quantity by a scalar value_type if divide_typeof_helper<value_type,value_type>::type is convertible to value_type
    281281        this_type& operator/=(const value_type& source) { val_ /= source; return *this; }
    282282   
     283        this_type& operator++()
     284        { ++val_; return *this; }
     285        this_type operator++(int)
     286        { this_type rval = *this; val_++; return rval; }
     287
     288        this_type& operator--()
     289        { --val_; return *this; }
     290        this_type operator--(int)
     291        { this_type rval = *this; val_--; return rval; }
     292
    283293        /// Construct quantity directly from @c value_type (potentially dangerous).
    284294        static this_type from_value(const value_type& val)  { return this_type(val, 0); }
    285295
    operator/(const quantity<Unit1,X>& lhs,  
    11391149    return type::from_value(lhs.value()/rhs.value());
    11401150}
    11411151
     1152/// runtime operator%
     1153template <class Unit, class X, class Y>
     1154inline
     1155quantity<Unit,X> operator%(const quantity<Unit,X>& lhs, const Y& rhs)
     1156{ return quantity<Unit,X>::from_value(lhs.value() % rhs); }
     1157
    11421158/// runtime operator==
    11431159template<class Unit,
    11441160         class X,