Skip to content

Commit ca58c03

Browse files
committed
[libc++] Avoid having to export __builtin_common_type from common_type.h
1 parent 114cc54 commit ca58c03

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

libcxx/include/__type_traits/common_type.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <__type_traits/type_identity.h>
1818
#include <__type_traits/void_t.h>
1919
#include <__utility/declval.h>
20-
#include <__utility/empty.h>
2120

2221
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2322
# pragma GCC system_header
@@ -33,8 +32,24 @@ struct common_type;
3332
template <class... _Args>
3433
using __common_type_t = typename common_type<_Args...>::type;
3534

35+
struct __no_common_type {
36+
using type = __no_common_type;
37+
};
38+
39+
template <class _Common>
40+
struct __common_type_impl {
41+
using type = _Common;
42+
};
43+
44+
template <>
45+
struct __common_type_impl<__no_common_type> {};
46+
47+
// We can't just inherit from __builtin_common_type, because that would require exporting __builtin_common_type
48+
// from this module and there's no way to do that.
3649
template <class... _Args>
37-
struct common_type : __builtin_common_type<__common_type_t, __type_identity, __empty, _Args...> {};
50+
struct common_type
51+
: __common_type_impl<
52+
typename __builtin_common_type<__common_type_t, __type_identity, __no_common_type, _Args...>::type> {};
3853

3954
#else
4055
# if _LIBCPP_STD_VER >= 20

0 commit comments

Comments
 (0)