fix doc example typo
[boost.git] / boost / units / detail / push_front_or_add.hpp
bloba3092da7661c9d17b6913810d39999c6685d16fb
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)
11 #ifndef BOOST_UNITS_DETAIL_PUSH_FRONT_OR_ADD_HPP
12 #define BOOST_UNITS_DETAIL_PUSH_FRONT_OR_ADD_HPP
14 #include <boost/mpl/plus.hpp>
15 #include <boost/mpl/front.hpp>
16 #include <boost/mpl/push_front.hpp>
17 #include <boost/mpl/pop_front.hpp>
18 #include <boost/type_traits/is_same.hpp>
20 #include <boost/units/units_fwd.hpp>
21 #include <boost/units/detail/push_front_if.hpp>
23 namespace boost {
25 namespace units {
27 template<class Item, class Next>
28 struct list;
30 namespace detail {
32 template<class T>
33 struct is_empty_dim;
35 /// add an instantiation of dim to Sequence.
36 template<bool>
37 struct push_front_or_add_impl;
39 template<>
40 struct push_front_or_add_impl<true>
42 template<typename Sequence, typename T>
43 struct apply
45 typedef typename mpl::plus<T, typename Sequence::item>::type item;
46 typedef typename push_front_if<!is_empty_dim<item>::value>::template apply<
47 typename Sequence::next,
48 item
49 > type;
53 template<>
54 struct push_front_or_add_impl<false>
56 template<typename Sequence, typename T>
57 struct apply
59 typedef list<T, Sequence> type;
63 template<typename Sequence, typename T>
64 struct push_front_or_add
66 typedef typename push_front_or_add_impl<boost::is_same<typename T::tag_type, typename Sequence::item::tag_type>::value>::template apply<
67 Sequence,
69 >::type type;
72 template<typename T>
73 struct push_front_or_add<dimensionless_type, T>
75 typedef list<T, dimensionless_type> type;
78 } // namespace detail
80 } // namespace units
82 } // namespace boost
84 #endif