#ifndef BOOST_TYPE_TRAITS_COMMON_TYPE_HPP_INCLUDED #define BOOST_TYPE_TRAITS_COMMON_TYPE_HPP_INCLUDED // // Copyright 2015 Peter Dimov // // 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 // #include #include #include #include #if defined(BOOST_NO_CXX11_DECLTYPE) #include #endif #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include #endif namespace boost { // variadic common_type #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template struct common_type { }; #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) template using common_type_t = typename common_type::type; namespace type_traits_detail { template using common_type_fold = common_type_t, T...>; } // namespace type_traits_detail template struct common_type: type_traits_detail::mp_defer { }; #else template struct common_type: common_type::type, T...> { }; #endif // !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) #else template< class T1 = void, class T2 = void, class T3 = void, class T4 = void, class T5 = void, class T6 = void, class T7 = void, class T8 = void, class T9 = void > struct common_type: common_type::type, T3, T4, T5, T6, T7, T8, T9> { }; #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) // one argument template struct common_type: boost::decay { }; // two arguments namespace type_traits_detail { // binary common_type #if !defined(BOOST_NO_CXX11_DECLTYPE) #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #if !defined(BOOST_MSVC) || BOOST_MSVC > 1800 // internal compiler error on msvc-12.0 template using builtin_common_type = typename boost::decay()? boost::declval(): boost::declval() )>::type; template struct common_type_impl: mp_defer { }; #else template using builtin_common_type = decltype( boost::declval()? boost::declval(): boost::declval() ); template struct common_type_impl_2: mp_defer { }; template using decay_common_type = typename boost::decay::type>::type; template struct common_type_impl: mp_defer { }; #endif // !defined(BOOST_MSVC) || BOOST_MSVC > 1800 #else template struct common_type_impl: boost::decay()? boost::declval(): boost::declval() )> { }; #endif // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #endif // #if !defined(BOOST_NO_CXX11_DECLTYPE) // decay helper template::type, class T2d = typename boost::decay::type> struct common_type_decay_helper: boost::common_type { }; template struct common_type_decay_helper: common_type_impl { }; } // type_traits_detail template struct common_type: type_traits_detail::common_type_decay_helper { }; } // namespace boost #endif // #ifndef BOOST_TYPE_TRAITS_COMMON_TYPE_HPP_INCLUDED