Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/units/base_dimension.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Boost.Units - A C++ library for zero-overhead dimensional analysis and 
0002 // unit/quantity manipulation and conversion
0003 //
0004 // Copyright (C) 2003-2008 Matthias Christian Schabel
0005 // Copyright (C) 2007-2008 Steven Watanabe
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See
0008 // accompanying file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 /// \file
0012 /// \brief base dimensions (mass, length, time...).
0013 /// \details base dimension definition registration.
0014 
0015 #ifndef BOOST_UNITS_BASE_DIMENSION_HPP
0016 #define BOOST_UNITS_BASE_DIMENSION_HPP
0017 
0018 #include <boost/units/config.hpp>
0019 #include <boost/units/dim.hpp>
0020 #include <boost/units/static_rational.hpp>
0021 #include <boost/units/units_fwd.hpp>
0022 #include <boost/units/detail/dimension_list.hpp>
0023 #include <boost/units/detail/ordinal.hpp>
0024 #include <boost/units/detail/prevent_redefinition.hpp>
0025 
0026 namespace boost {
0027 
0028 namespace units {
0029 
0030 /// This must be in namespace boost::units so that ADL
0031 /// will work with friend functions defined inline.
0032 /// INTERNAL ONLY
0033 template<long N> struct base_dimension_ordinal { };
0034 
0035 /// INTERNAL ONLY
0036 template<class T, long N> struct base_dimension_pair { };
0037 
0038 /// INTERNAL ONLY
0039 template<class T, long N>
0040 struct check_base_dimension {
0041     enum {
0042         value = 
0043             sizeof(boost_units_is_registered(units::base_dimension_ordinal<N>())) == sizeof(detail::yes) &&
0044             sizeof(boost_units_is_registered(units::base_dimension_pair<T, N>())) != sizeof(detail::yes)
0045     };
0046 };
0047 
0048 /// Defines a base dimension.  To define a dimension you need to provide
0049 /// the derived class (CRTP) and a unique integer.
0050 /// @code
0051 /// struct my_dimension : boost::units::base_dimension<my_dimension, 1> {};
0052 /// @endcode
0053 /// It is designed so that you will get an error message if you try
0054 /// to use the same value in multiple definitions.
0055 template<class Derived,
0056          long N
0057 #if !defined(BOOST_UNITS_DOXYGEN) && !defined(BOOST_BORLANDC)
0058          ,
0059          class = typename detail::ordinal_has_already_been_defined<
0060              check_base_dimension<Derived, N>::value
0061          >::type
0062 #endif
0063 >
0064 class base_dimension : 
0065     public ordinal<N> 
0066 {
0067     public:
0068         /// INTERNAL ONLY
0069         typedef base_dimension                                                          this_type;
0070         /// A convenience typedef.  Equivalent to boost::units::derived_dimension<Derived,1>::type.
0071 #ifndef BOOST_UNITS_DOXYGEN 
0072         typedef list<dim<Derived,static_rational<1> >, dimensionless_type>    dimension_type;
0073 #else
0074         typedef detail::unspecified dimension_type;
0075 #endif
0076         /// Provided for mpl compatability.
0077         typedef Derived type;
0078 
0079     private:
0080         /// Check for C++0x.  In C++0x, we have to have identical
0081         /// arguments but a different return type to trigger an
0082         /// error.  Note that this is only needed for clang as
0083         /// check_base_dimension will trigger an error earlier
0084         /// for compilers with less strict name lookup.
0085         /// INTERNAL ONLY
0086         friend BOOST_CONSTEXPR Derived* 
0087         check_double_register(const units::base_dimension_ordinal<N>&) 
0088         { return(0); }
0089 
0090         /// Register this ordinal
0091         /// INTERNAL ONLY
0092         friend BOOST_CONSTEXPR detail::yes 
0093         boost_units_is_registered(const units::base_dimension_ordinal<N>&) 
0094         { return(detail::yes()); }
0095         
0096         /// But make sure we can identify the current instantiation!
0097         /// INTERNAL ONLY
0098         friend BOOST_CONSTEXPR detail::yes 
0099         boost_units_is_registered(const units::base_dimension_pair<Derived, N>&) 
0100         { return(detail::yes()); }
0101 };
0102 
0103 } // namespace units
0104 
0105 } // namespace boost
0106 
0107 #endif // BOOST_UNITS_BASE_DIMENSION_HPP