]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/units/include/boost/units/detail/push_front_or_add.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / units / include / boost / units / detail / push_front_or_add.hpp
CommitLineData
7c673cae
FG
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_DETAIL_PUSH_FRONT_OR_ADD_HPP
12#define BOOST_UNITS_DETAIL_PUSH_FRONT_OR_ADD_HPP
13
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>
19
20#include <boost/units/units_fwd.hpp>
21#include <boost/units/detail/push_front_if.hpp>
22
23namespace boost {
24
25namespace units {
26
27template<class Item, class Next>
28struct list;
29
30namespace detail {
31
32template<class T>
33struct is_empty_dim;
34
35/// add an instantiation of dim to Sequence.
36template<bool>
37struct push_front_or_add_impl;
38
39template<>
40struct push_front_or_add_impl<true>
41{
42 template<typename Sequence, typename T>
43 struct apply
44 {
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;
50 };
51};
52
53template<>
54struct push_front_or_add_impl<false>
55{
56 template<typename Sequence, typename T>
57 struct apply
58 {
59 typedef list<T, Sequence> type;
60 };
61};
62
63template<typename Sequence, typename T>
64struct push_front_or_add
65{
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,
68 T
69 >::type type;
70};
71
72template<typename T>
73struct push_front_or_add<dimensionless_type, T>
74{
75 typedef list<T, dimensionless_type> type;
76};
77
78} // namespace detail
79
80} // namespace units
81
82} // namespace boost
83
84#endif