blob: a3092da7661c9d17b6913810d39999c6685d16fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
// Boost.Units - A C++ library for zero-overhead dimensional analysis and
// unit/quantity manipulation and conversion
//
// Copyright (C) 2003-2008 Matthias Christian Schabel
// Copyright (C) 2008 Steven Watanabe
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_UNITS_DETAIL_PUSH_FRONT_OR_ADD_HPP
#define BOOST_UNITS_DETAIL_PUSH_FRONT_OR_ADD_HPP
#include <boost/mpl/plus.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/units/units_fwd.hpp>
#include <boost/units/detail/push_front_if.hpp>
namespace boost {
namespace units {
template<class Item, class Next>
struct list;
namespace detail {
template<class T>
struct is_empty_dim;
/// add an instantiation of dim to Sequence.
template<bool>
struct push_front_or_add_impl;
template<>
struct push_front_or_add_impl<true>
{
template<typename Sequence, typename T>
struct apply
{
typedef typename mpl::plus<T, typename Sequence::item>::type item;
typedef typename push_front_if<!is_empty_dim<item>::value>::template apply<
typename Sequence::next,
item
> type;
};
};
template<>
struct push_front_or_add_impl<false>
{
template<typename Sequence, typename T>
struct apply
{
typedef list<T, Sequence> type;
};
};
template<typename Sequence, typename T>
struct push_front_or_add
{
typedef typename push_front_or_add_impl<boost::is_same<typename T::tag_type, typename Sequence::item::tag_type>::value>::template apply<
Sequence,
T
>::type type;
};
template<typename T>
struct push_front_or_add<dimensionless_type, T>
{
typedef list<T, dimensionless_type> type;
};
} // namespace detail
} // namespace units
} // namespace boost
#endif
|