Chris@16: // Boost.Units - A C++ library for zero-overhead dimensional analysis and Chris@16: // unit/quantity manipulation and conversion Chris@16: // Chris@16: // Copyright (C) 2003-2008 Matthias Christian Schabel Chris@16: // Copyright (C) 2007-2008 Steven Watanabe Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: /// \file Chris@16: /// \brief base dimensions (mass, length, time...). Chris@16: /// \details base dimension definition registration. Chris@16: Chris@16: #ifndef BOOST_UNITS_BASE_DIMENSION_HPP Chris@16: #define BOOST_UNITS_BASE_DIMENSION_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: namespace units { Chris@16: Chris@16: /// This must be in namespace boost::units so that ADL Chris@16: /// will work with friend functions defined inline. Chris@16: /// INTERNAL ONLY Chris@16: template struct base_dimension_ordinal { }; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template struct base_dimension_pair { }; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template Chris@16: struct check_base_dimension { Chris@16: enum { Chris@16: value = Chris@16: sizeof(boost_units_is_registered(units::base_dimension_ordinal())) == sizeof(detail::yes) && Chris@16: sizeof(boost_units_is_registered(units::base_dimension_pair())) != sizeof(detail::yes) Chris@16: }; Chris@16: }; Chris@16: Chris@16: /// Defines a base dimension. To define a dimension you need to provide Chris@16: /// the derived class (CRTP) and a unique integer. Chris@16: /// @code Chris@16: /// struct my_dimension : boost::units::base_dimension {}; Chris@16: /// @endcode Chris@16: /// It is designed so that you will get an error message if you try Chris@16: /// to use the same value in multiple definitions. Chris@16: template::value Chris@16: >::type Chris@16: #endif Chris@16: > Chris@16: class base_dimension : Chris@16: public ordinal Chris@16: { Chris@16: public: Chris@16: /// INTERNAL ONLY Chris@16: typedef base_dimension this_type; Chris@16: /// A convenience typedef. Equivalent to boost::units::derived_dimension::type. Chris@16: #ifndef BOOST_UNITS_DOXYGEN Chris@16: typedef list >, dimensionless_type> dimension_type; Chris@16: #else Chris@16: typedef detail::unspecified dimension_type; Chris@16: #endif Chris@16: /// Provided for mpl compatability. Chris@16: typedef Derived type; Chris@16: Chris@16: private: Chris@16: /// Check for C++0x. In C++0x, we have to have identical Chris@16: /// arguments but a different return type to trigger an Chris@16: /// error. Note that this is only needed for clang as Chris@16: /// check_base_dimension will trigger an error earlier Chris@16: /// for compilers with less strict name lookup. Chris@16: /// INTERNAL ONLY Chris@16: friend Derived* Chris@16: check_double_register(const units::base_dimension_ordinal&) Chris@16: { return(0); } Chris@16: Chris@16: /// Register this ordinal Chris@16: /// INTERNAL ONLY Chris@16: friend detail::yes Chris@16: boost_units_is_registered(const units::base_dimension_ordinal&) Chris@16: { detail::yes result; return(result); } Chris@16: Chris@16: /// But make sure we can identify the current instantiation! Chris@16: /// INTERNAL ONLY Chris@16: friend detail::yes Chris@16: boost_units_is_registered(const units::base_dimension_pair&) Chris@16: { detail::yes result; return(result); } Chris@16: }; Chris@16: Chris@16: } // namespace units Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #endif // BOOST_UNITS_BASE_DIMENSION_HPP