File indexing completed on 2025-12-15 10:09:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_UNITS_BASE_UNIT_HPP
0016 #define BOOST_UNITS_BASE_UNIT_HPP
0017
0018 #include <boost/units/config.hpp>
0019 #include <boost/units/heterogeneous_system.hpp>
0020 #include <boost/units/static_rational.hpp>
0021 #include <boost/units/units_fwd.hpp>
0022 #include <boost/units/unit.hpp>
0023 #include <boost/units/detail/dimension_list.hpp>
0024 #include <boost/units/detail/ordinal.hpp>
0025 #include <boost/units/detail/prevent_redefinition.hpp>
0026
0027 namespace boost {
0028
0029 namespace units {
0030
0031
0032
0033
0034
0035 template<long N> struct base_unit_ordinal { };
0036
0037
0038 template<class T, long N> struct base_unit_pair { };
0039
0040
0041 template<class T, long N>
0042 struct check_base_unit {
0043 enum {
0044 value =
0045 sizeof(boost_units_unit_is_registered(units::base_unit_ordinal<N>())) == sizeof(detail::yes) &&
0046 sizeof(boost_units_unit_is_registered(units::base_unit_pair<T, N>())) != sizeof(detail::yes)
0047 };
0048 };
0049
0050
0051
0052
0053
0054
0055
0056
0057 template<class Derived,
0058 class Dim,
0059 long N
0060 #if !defined(BOOST_UNITS_DOXYGEN) && !defined(BOOST_BORLANDC)
0061 ,
0062 class = typename detail::ordinal_has_already_been_defined<
0063 check_base_unit<Derived, N>::value
0064 >::type
0065 #endif
0066 >
0067 class base_unit :
0068 public ordinal<N>
0069 {
0070 public:
0071
0072 typedef void boost_units_is_base_unit_type;
0073
0074 typedef base_unit this_type;
0075
0076 typedef Dim dimension_type;
0077
0078
0079 typedef Derived type;
0080
0081
0082 #ifndef BOOST_UNITS_DOXYGEN
0083 typedef unit<
0084 Dim,
0085 heterogeneous_system<
0086 heterogeneous_system_impl<
0087 list<
0088 heterogeneous_system_dim<Derived,static_rational<1> >,
0089 dimensionless_type
0090 >,
0091 Dim,
0092 no_scale
0093 >
0094 >
0095 > unit_type;
0096 #else
0097 typedef detail::unspecified unit_type;
0098 #endif
0099
0100 private:
0101
0102
0103
0104
0105
0106
0107 friend BOOST_CONSTEXPR Derived*
0108 check_double_register(const units::base_unit_ordinal<N>&)
0109 { return(0); }
0110
0111
0112
0113 friend BOOST_CONSTEXPR detail::yes
0114 boost_units_unit_is_registered(const units::base_unit_ordinal<N>&)
0115 { return(detail::yes()); }
0116
0117
0118
0119 friend BOOST_CONSTEXPR detail::yes
0120 boost_units_unit_is_registered(const units::base_unit_pair<Derived, N>&)
0121 { return(detail::yes()); }
0122 };
0123
0124 }
0125
0126 }
0127
0128 #endif