1// Boost.Units - A C++ library for zero-overhead dimensional analysis and
2// unit/quantity manipulation and conversion
3//
4// Copyright (C) 2003-2008 Matthias Christian Schabel
5// Copyright (C) 2008 Steven Watanabe
6//
7// Distributed under the Boost Software License, Version 1.0. (See
8// accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10
11#ifndef BOOST_UNITS_HOMOGENEOUS_SYSTEM_HPP_INCLUDED
12#define BOOST_UNITS_HOMOGENEOUS_SYSTEM_HPP_INCLUDED
13
14#include <boost/mpl/bool.hpp>
15
16#include <boost/units/config.hpp>
17#include <boost/units/static_rational.hpp>
18
19#ifdef BOOST_UNITS_CHECK_HOMOGENEOUS_UNITS
20
21#include <boost/type_traits/is_same.hpp>
22#include <boost/mpl/not.hpp>
23
24#include <boost/units/detail/linear_algebra.hpp>
25
26#endif
27
28namespace boost {
29
30namespace units {
31
32/// A system that can uniquely represent any unit
33/// which can be composed from a linearly independent set
34/// of base units. It is safe to rebind a unit with
35/// such a system to different dimensions.
36///
37/// Do not construct this template directly. Use
38/// make_system instead.
39template<class L>
40struct homogeneous_system {
41 /// INTERNAL ONLY
42 typedef L type;
43};
44
45template<class T, class E>
46struct static_power;
47
48template<class T, class R>
49struct static_root;
50
51/// INTERNAL ONLY
52template<class L, long N, long D>
53struct static_power<homogeneous_system<L>, static_rational<N,D> >
54{
55 typedef homogeneous_system<L> type;
56};
57
58/// INTERNAL ONLY
59template<class L, long N, long D>
60struct static_root<homogeneous_system<L>, static_rational<N,D> >
61{
62 typedef homogeneous_system<L> type;
63};
64
65namespace detail {
66
67template<class System, class Dimensions>
68struct check_system;
69
70#ifdef BOOST_UNITS_CHECK_HOMOGENEOUS_UNITS
71
72template<class L, class Dimensions>
73struct check_system<homogeneous_system<L>, Dimensions> :
74 boost::mpl::not_<
75 boost::is_same<
76 typename calculate_base_unit_exponents<
77 L,
78 Dimensions
79 >::type,
80 inconsistent
81 >
82 > {};
83
84#else
85
86template<class L, class Dimensions>
87struct check_system<homogeneous_system<L>, Dimensions> : mpl::true_ {};
88
89#endif
90
91} // namespace detail
92
93} // namespace units
94
95} // namespace boost
96
97#if BOOST_UNITS_HAS_BOOST_TYPEOF
98
99#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
100
101BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::homogeneous_system, (class))
102
103#endif
104
105#endif
106

source code of boost/boost/units/homogeneous_system.hpp