1 // Boost.Units - A C++ library for zero-overhead dimensional analysis and
2 // unit/quantity manipulation and conversion
4 // Copyright (C) 2003-2008 Matthias Christian Schabel
5 // Copyright (C) 2008 Steven Watanabe
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>
27 template<class Item
, class Next
>
35 /// add an instantiation of dim to Sequence.
37 struct push_front_or_add_impl
;
40 struct push_front_or_add_impl
<true>
42 template<typename Sequence
, typename T
>
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
,
54 struct push_front_or_add_impl
<false>
56 template<typename Sequence
, typename T
>
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
<
73 struct push_front_or_add
<dimensionless_type
, T
>
75 typedef list
<T
, dimensionless_type
> type
;