File indexing completed on 2025-01-30 10:01:38
0001 #ifndef BOOST_TYPE_TRAITS_COMMON_TYPE_HPP_INCLUDED
0002 #define BOOST_TYPE_TRAITS_COMMON_TYPE_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <boost/config.hpp>
0013 #include <boost/type_traits/decay.hpp>
0014 #include <boost/type_traits/declval.hpp>
0015 #include <boost/detail/workaround.hpp>
0016 #include <boost/type_traits/is_complete.hpp>
0017 #include <boost/type_traits/is_void.hpp>
0018 #include <boost/type_traits/is_array.hpp>
0019 #include <boost/static_assert.hpp>
0020
0021 #if defined(BOOST_NO_CXX11_DECLTYPE)
0022 #include <boost/type_traits/detail/common_type_impl.hpp>
0023 #endif
0024
0025 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0026 #include <boost/type_traits/detail/mp_defer.hpp>
0027 #endif
0028
0029 namespace boost
0030 {
0031
0032
0033
0034 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0035
0036 template<class... T> struct common_type
0037 {
0038 };
0039
0040 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
0041
0042 template<class... T> using common_type_t = typename common_type<T...>::type;
0043
0044 namespace type_traits_detail
0045 {
0046
0047 template<class T1, class T2, class... T> using common_type_fold = common_type_t<common_type_t<T1, T2>, T...>;
0048
0049 }
0050
0051 template<class T1, class T2, class... T>
0052 struct common_type<T1, T2, T...>: type_traits_detail::mp_defer<type_traits_detail::common_type_fold, T1, T2, T...>
0053 {
0054 };
0055
0056 #else
0057
0058 template<class T1, class T2, class... T>
0059 struct common_type<T1, T2, T...>: common_type<typename common_type<T1, T2>::type, T...>
0060 {
0061 };
0062
0063 #endif
0064
0065 #else
0066
0067 template<
0068 class T1 = void, class T2 = void, class T3 = void,
0069 class T4 = void, class T5 = void, class T6 = void,
0070 class T7 = void, class T8 = void, class T9 = void
0071 >
0072 struct common_type: common_type<typename common_type<T1, T2>::type, T3, T4, T5, T6, T7, T8, T9>
0073 {
0074 };
0075
0076 #endif
0077
0078
0079
0080 template<class T> struct common_type<T>: boost::decay<T>
0081 {
0082 BOOST_STATIC_ASSERT_MSG(::boost::is_complete<T>::value || ::boost::is_void<T>::value || ::boost::is_array<T>::value, "Arguments to common_type must both be complete types");
0083 };
0084
0085
0086
0087 namespace type_traits_detail
0088 {
0089
0090
0091
0092 #if !defined(BOOST_NO_CXX11_DECLTYPE)
0093
0094 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0095
0096 #if !defined(BOOST_MSVC) || BOOST_MSVC > 1800
0097
0098
0099
0100 template<class T1, class T2> using builtin_common_type = typename boost::decay<decltype( boost::declval<bool>()? boost::declval<T1>(): boost::declval<T2>() )>::type;
0101
0102 template<class T1, class T2> struct common_type_impl: mp_defer<builtin_common_type, T1, T2>
0103 {
0104 };
0105
0106 #else
0107
0108 template<class T1, class T2> using builtin_common_type = decltype( boost::declval<bool>()? boost::declval<T1>(): boost::declval<T2>() );
0109
0110 template<class T1, class T2> struct common_type_impl_2: mp_defer<builtin_common_type, T1, T2>
0111 {
0112 };
0113
0114 template<class T1, class T2> using decay_common_type = typename boost::decay<typename common_type_impl_2<T1, T2>::type>::type;
0115
0116 template<class T1, class T2> struct common_type_impl: mp_defer<decay_common_type, T1, T2>
0117 {
0118 };
0119
0120 #endif
0121
0122 #else
0123
0124 template<class T1, class T2> struct common_type_impl: boost::decay<decltype( boost::declval<bool>()? boost::declval<T1>(): boost::declval<T2>() )>
0125 {
0126 };
0127
0128 #endif
0129
0130 #endif
0131
0132
0133
0134 template<class T1, class T2, class T1d = typename boost::decay<T1>::type, class T2d = typename boost::decay<T2>::type> struct common_type_decay_helper: boost::common_type<T1d, T2d>
0135 {
0136 };
0137
0138 template<class T1, class T2> struct common_type_decay_helper<T1, T2, T1, T2>: common_type_impl<T1, T2>
0139 {
0140 };
0141
0142 }
0143
0144 template<class T1, class T2> struct common_type<T1, T2>: type_traits_detail::common_type_decay_helper<T1, T2>
0145 {
0146 BOOST_STATIC_ASSERT_MSG(::boost::is_complete<T1>::value || ::boost::is_void<T1>::value || ::boost::is_array<T1>::value, "Arguments to common_type must both be complete types");
0147 BOOST_STATIC_ASSERT_MSG(::boost::is_complete<T2>::value || ::boost::is_void<T2>::value || ::boost::is_array<T2>::value, "Arguments to common_type must both be complete types");
0148 };
0149
0150 }
0151
0152 #endif