Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:14

0001 // Boost.Units - A C++ library for zero-overhead dimensional analysis and 
0002 // unit/quantity manipulation and conversion
0003 //
0004 // Copyright (C) 2003-2008 Matthias Christian Schabel
0005 // Copyright (C) 2008 Steven Watanabe
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See
0008 // accompanying file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 #ifndef BOOST_UNITS_DETAIL_PUSH_FRONT_OR_ADD_HPP
0012 #define BOOST_UNITS_DETAIL_PUSH_FRONT_OR_ADD_HPP
0013 
0014 #include <boost/mpl/plus.hpp>
0015 #include <boost/mpl/front.hpp>
0016 #include <boost/mpl/push_front.hpp>
0017 #include <boost/mpl/pop_front.hpp>
0018 #include <boost/type_traits/is_same.hpp>
0019 
0020 #include <boost/units/units_fwd.hpp>
0021 #include <boost/units/detail/push_front_if.hpp>
0022 
0023 namespace boost {
0024 
0025 namespace units {
0026 
0027 template<class Item, class Next>
0028 struct list;
0029 
0030 namespace detail {
0031 
0032 template<class T>
0033 struct is_empty_dim;
0034 
0035 /// add an instantiation of dim to Sequence.
0036 template<bool>
0037 struct push_front_or_add_impl;
0038 
0039 template<>
0040 struct push_front_or_add_impl<true>
0041 {
0042     template<typename Sequence, typename T>
0043     struct apply
0044     {
0045         typedef typename mpl::plus<T, typename Sequence::item>::type item;
0046         typedef typename push_front_if<!is_empty_dim<item>::value>::template apply<
0047             typename Sequence::next,
0048             item
0049         > type;
0050     };
0051 };
0052 
0053 template<>
0054 struct push_front_or_add_impl<false>
0055 {
0056     template<typename Sequence, typename T>
0057     struct apply
0058     {
0059         typedef list<T, Sequence> type;
0060     };
0061 };
0062 
0063 template<typename Sequence, typename T>
0064 struct push_front_or_add
0065 {
0066     typedef typename push_front_or_add_impl<boost::is_same<typename T::tag_type, typename Sequence::item::tag_type>::value>::template apply<
0067         Sequence,
0068         T
0069     >::type type;
0070 };
0071 
0072 template<typename T>
0073 struct push_front_or_add<dimensionless_type, T>
0074 {
0075     typedef list<T, dimensionless_type> type;
0076 };
0077 
0078 } // namespace detail
0079 
0080 } // namespace units
0081 
0082 } // namespace boost
0083 
0084 #endif