#include namespace std { namespace trigo { template> class angle; template class angle { // represents a time duration public: typedef angle<_Rep, _Period> _Myt; typedef _Rep rep; typedef _Period period; angle() : _MyRep() { // check asserts static_assert( _Is_ratio<_Period>::value, "period must be an instance of std::ratio" ); static_assert(0 < _Period::num, "duration negative or zero"); } template< class _Rep2, class = typename enable_if< is_convertible<_Rep2, _Rep>::value && (treat_as_floating_point<_Rep>::value || !treat_as_floating_point<_Rep2>::value ), void>::type > // construct from representation explicit angle(const _Rep2& _Val) : _MyRep(static_cast<_Rep>(_Val)) { static_assert( _Is_ratio<_Period>::value, "period not an instance of std::ratio" ); static_assert(0 < _Period::num, "duration negative or zero"); } /* template< class _Rep2, class _Period2, class = typename enable_if< treat_as_floating_point<_Rep>::value || (ratio_divide<_Period2, _Period>::den == 1 && !treat_as_floating_point<_Rep2>::value ), void>::type > angle(const duration<_Rep2, _Period2>& _Dur) : _MyRep(duration_cast<_Myt>(_Dur).count()) { // construct from a duration typedef ratio_divide<_Period2, _Period> _Checked_type; static_assert( _Is_ratio<_Period>::value, "period not an instance of std::ratio" ); static_assert(0 < _Period::num, "duration negative or zero"); } */ _Rep count() const { // get stored rep return (_MyRep); } _Myt operator+() const { // get value return (*this); } _Myt operator-() const { // get negated value return (_Myt(0 - _MyRep)); } _Myt& operator++() { // increment rep ++_MyRep; return (*this); } _Myt operator++(int) { // postincrement rep return (_Myt(_MyRep++)); } _Myt& operator--() { // decrement rep --_MyRep; return (*this); } _Myt operator--(int) { // postdecrement rep return (_Myt(_MyRep--)); } _Myt& operator+=(const _Myt& _Right) { // add _Right to rep _MyRep += _Right._MyRep; return (*this); } _Myt& operator-=(const _Myt& _Right) { // subtract _Right from rep _MyRep -= _Right._MyRep; return (*this); } _Myt& operator*=(const _Rep& _Right) { // multiply rep by _Right _MyRep *= _Right; return (*this); } _Myt& operator/=(const _Rep& _Right) { // divide rep by _Right _MyRep /= _Right; return (*this); } _Myt& operator%=(const _Rep& _Right) { // modulus rep by _Right _MyRep %= _Right; return (*this); } _Myt& operator%=(const _Myt& _Right) { // modulus rep by _Right _MyRep %= _Right.count(); return (*this); } static _Myt zero() { // get zero value return (_Myt(duration_values<_Rep>::zero())); } static _Myt(min)() { // get minimum value return (_Myt((duration_values<_Rep>::min)())); } static _Myt(max)() { // get maximum value return (_Myt((duration_values<_Rep>::max)())); } private: _Rep _MyRep; // the stored rep }; //typedef angle // With degrees as the base unit typedef angle degrees; typedef angle> radians; typedef angle> turns; typedef angle> grads; // With radians as the base unit typedef angle radians; typedef angle> degrees; typedef angle> turns; typedef angle> grads; }} // namespace std::trigo inline void a(std::trigo::radians angle) { } inline void b() { a(std::trigo::degrees(180)); } }} // namespace std::trigo