|
From: Matthias S. <mat...@us...> - 2007-04-15 06:51:04
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23868/boost/units Modified Files: base_dimension.hpp Log Message: move base_dimension internals to private Index: base_dimension.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/base_dimension.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- base_dimension.hpp 15 Apr 2007 02:09:19 -0000 1.6 +++ base_dimension.hpp 15 Apr 2007 06:51:00 -0000 1.7 @@ -28,33 +28,32 @@ typedef char no; struct yes { no dummy[2]; }; -template<bool> -struct ordinal_has_already_been_defined; +template<bool> struct ordinal_has_already_been_defined; template<> -struct ordinal_has_already_been_defined<true> {}; +struct ordinal_has_already_been_defined<true> { }; template<> -struct ordinal_has_already_been_defined<false> { typedef void type; }; +struct ordinal_has_already_been_defined<false> { typedef void type; }; } /// This must be in namespace boost::units so that ADL /// will work with friend functions defined inline. /// INTERNAL ONLY -template<long N> -struct long_ {}; - -/// Ditto. -/// INTERNAL ONLY -template<class T, long N> -struct base_dimension_pair {}; +template<long N> struct long_ { }; /// Again this needs to be in the same namespace as long_ /// we need a mangled name because it must be found by ADL /// INTERNAL ONLY template<class T> -detail::no boost_units_prevent_double_definition(const T&) { return(detail::no()); } +detail::no +boost_units_prevent_redefinition(const T&) +{ return(detail::no()); } + +/// Ditto. +/// INTERNAL ONLY +template<class T, long N> struct base_dimension_pair { }; /// Defines a base dimension. To define a dimension you need to provide /// the derived class (CRTP) and a unique integer. @@ -64,19 +63,29 @@ template<class Derived, long N, class = typename detail::ordinal_has_already_been_defined< - sizeof(boost_units_prevent_double_definition(units::long_<N>())) == sizeof(detail::yes) && - sizeof(boost_units_prevent_double_definition(units::base_dimension_pair<Derived, N>())) != sizeof(detail::yes) + sizeof(boost_units_prevent_redefinition(units::long_<N>())) == sizeof(detail::yes) && + sizeof(boost_units_prevent_redefinition(units::base_dimension_pair<Derived, N>())) != sizeof(detail::yes) >::type> -struct base_dimension : mpl::long_<N> { - /// Register this ordinal - /// INTERNAL ONLY - friend detail::yes boost_units_prevent_double_definition(const units::long_<N>&) { return(detail::yes()); } - /// But make sure we can identify the current instantiation! - /// INTERNAL ONLY - friend detail::yes boost_units_prevent_double_definition(const units::base_dimension_pair<Derived, N>&) { return(detail::yes()); } - typedef base_dimension this_type; - typedef mpl::long_<N> value; - typedef dimension_list<dim<Derived,static_rational<1> >, dimensionless_type> type; +class base_dimension : + public mpl::long_<N> +{ + public: + typedef base_dimension this_type; + typedef mpl::long_<N> value; + typedef dimension_list<dim<Derived,static_rational<1> >, dimensionless_type> type; + + private: + /// Register this ordinal + /// INTERNAL ONLY + friend detail::yes + boost_units_prevent_redefinition(const units::long_<N>&) + { return(detail::yes()); } + + /// But make sure we can identify the current instantiation! + /// INTERNAL ONLY + friend detail::yes + boost_units_prevent_redefinition(const units::base_dimension_pair<Derived, N>&) + { return(detail::yes()); } }; } // namespace units |