Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:55

0001 #ifndef BOOST_MP11_DETAIL_MP_PLUS_HPP_INCLUDED
0002 #define BOOST_MP11_DETAIL_MP_PLUS_HPP_INCLUDED
0003 
0004 //  Copyright 2015 Peter Dimov.
0005 //
0006 //  Distributed under the Boost Software License, Version 1.0.
0007 //
0008 //  See accompanying file LICENSE_1_0.txt or copy at
0009 //  http://www.boost.org/LICENSE_1_0.txt
0010 
0011 #include <boost/mp11/detail/config.hpp>
0012 #include <type_traits>
0013 
0014 namespace boost
0015 {
0016 namespace mp11
0017 {
0018 
0019 // mp_plus
0020 namespace detail
0021 {
0022 
0023 #if defined( BOOST_MP11_HAS_FOLD_EXPRESSIONS ) && !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, != 0 ) && !BOOST_MP11_WORKAROUND( BOOST_MP11_CLANG, != 0 )
0024 
0025 // msvc fails with parser stack overflow for large sizeof...(T)
0026 // clang exceeds -fbracket-depth, which defaults to 256
0027 
0028 template<class... T> struct mp_plus_impl
0029 {
0030     static const auto _v = (T::value + ... + 0);
0031     using type = std::integral_constant<typename std::remove_const<decltype(_v)>::type, _v>;
0032 };
0033 
0034 #else
0035 
0036 template<class... T> struct mp_plus_impl;
0037 
0038 template<> struct mp_plus_impl<>
0039 {
0040     using type = std::integral_constant<int, 0>;
0041 };
0042 
0043 #if BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 40800 )
0044 
0045 template<class T1, class... T> struct mp_plus_impl<T1, T...>
0046 {
0047     static const decltype(T1::value + mp_plus_impl<T...>::type::value) _v = T1::value + mp_plus_impl<T...>::type::value;
0048     using type = std::integral_constant<typename std::remove_const<decltype(_v)>::type, _v>;
0049 };
0050 
0051 template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class... T> struct mp_plus_impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T...>
0052 {
0053     static const
0054         decltype(T1::value + T2::value + T3::value + T4::value + T5::value + T6::value + T7::value + T8::value + T9::value + T10::value + mp_plus_impl<T...>::type::value)
0055         _v = T1::value + T2::value + T3::value + T4::value + T5::value + T6::value + T7::value + T8::value + T9::value + T10::value + mp_plus_impl<T...>::type::value;
0056     using type = std::integral_constant<typename std::remove_const<decltype(_v)>::type, _v>;
0057 };
0058 
0059 #else
0060 
0061 template<class T1, class... T> struct mp_plus_impl<T1, T...>
0062 {
0063     static const auto _v = T1::value + mp_plus_impl<T...>::type::value;
0064     using type = std::integral_constant<typename std::remove_const<decltype(_v)>::type, _v>;
0065 };
0066 
0067 template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class... T> struct mp_plus_impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T...>
0068 {
0069     static const auto _v = T1::value + T2::value + T3::value + T4::value + T5::value + T6::value + T7::value + T8::value + T9::value + T10::value + mp_plus_impl<T...>::type::value;
0070     using type = std::integral_constant<typename std::remove_const<decltype(_v)>::type, _v>;
0071 };
0072 
0073 #endif
0074 
0075 #endif
0076 
0077 } // namespace detail
0078 
0079 template<class... T> using mp_plus = typename detail::mp_plus_impl<T...>::type;
0080 
0081 } // namespace mp11
0082 } // namespace boost
0083 
0084 #endif // #ifndef BOOST_MP11_DETAIL_MP_PLUS_HPP_INCLUDED