1 // Test case reduced from an experimental std modules implementation.
2 // Tests that the compiler don't emit confusing error about the ambiguous ctor
7 // RUN: split-file %s %t
9 // RUN: %clang_cc1 -std=c++20 %t/string.cppm -I%t -emit-module-interface -o %t/std-string.pcm
10 // RUN: %clang_cc1 -std=c++20 %t/algorithm.cppm -I%t -emit-module-interface -o %t/std-algorithm.pcm
11 // RUN: %clang_cc1 -std=c++20 %t/Use.cppm -I%t -fprebuilt-module-path=%t -emit-module-interface -verify -o %t/Use.pcm
14 // expected-no-diagnostics
17 # 3 "pair-unambiguous-ctor.cppm" 1 3
19 # 3 "pair-unambiguous-ctor.cppm" 2 3
30 # 28 "pair-unambiguous-ctor.cppm" 1 3
31 export module std:string;
32 export namespace std {
35 # 28 "pair-unambiguous-ctor.cppm" 2 3
39 #include "algorithm.h"
40 # 38 "pair-unambiguous-ctor.cppm" 1 3
41 export module std:algorithm;
42 # 38 "pair-unambiguous-ctor.cppm" 2 3
45 namespace std __attribute__ ((__visibility__ ("default")))
47 typedef long unsigned int size_t;
48 typedef long int ptrdiff_t;
50 typedef decltype(nullptr) nullptr_t;
52 template<typename _Tp, _Tp __v>
53 struct integral_constant
55 static constexpr _Tp value = __v;
56 typedef _Tp value_type;
57 typedef integral_constant<_Tp, __v> type;
58 constexpr operator value_type() const noexcept { return value; }
59 constexpr value_type operator()() const noexcept { return value; }
62 template<typename _Tp, _Tp __v>
63 constexpr _Tp integral_constant<_Tp, __v>::value;
65 typedef integral_constant<bool, true> true_type;
66 typedef integral_constant<bool, false> false_type;
69 using __bool_constant = integral_constant<bool, __v>;
72 template<bool, typename, typename>
75 template<bool _Cond, typename _Iftrue, typename _Iffalse>
77 { typedef _Iftrue type; };
79 template<typename _Iftrue, typename _Iffalse>
80 struct conditional<false, _Iftrue, _Iffalse>
81 { typedef _Iffalse type; };
84 template<bool, typename _Tp = void>
89 template<typename _Tp>
90 struct enable_if<true, _Tp>
91 { typedef _Tp type; };
93 template<typename _Tp, typename... _Args>
94 struct __is_constructible_impl
95 : public __bool_constant<__is_constructible(_Tp, _Args...)>
99 template<typename _Tp, typename... _Args>
100 struct is_constructible
101 : public __is_constructible_impl<_Tp, _Args...>
105 struct __is_void_helper
106 : public false_type { };
109 struct __is_void_helper<void>
110 : public true_type { };
112 template<typename _Tp>
114 : public __is_void_helper<_Tp>::type
117 template<typename...>
120 template<std::size_t...>
123 template <bool, typename _T1, typename _T2>
126 template <typename _U1, typename _U2>
127 static constexpr bool _ConstructiblePair()
129 return is_constructible<_T1, const _U1&>::value;
134 template<typename _T1, typename _T2>
137 typedef _T1 first_type;
138 typedef _T2 second_type;
143 using _PCCP = _PCC<true, _T1, _T2>;
145 template<typename _U1 = _T1, typename _U2=_T2, typename
146 enable_if<_PCCP::template
147 _ConstructiblePair<_U1, _U2>(),
149 constexpr pair(const _T1& __a, const _T2& __b)
150 : first(__a), second(__b) { }
153 operator=(typename conditional<
154 is_constructible<_T2>::value,
155 const pair&, nullptr_t>::type __p)
163 template<typename... _Args1, std::size_t... _Indexes1,
164 typename... _Args2, std::size_t... _Indexes2>
166 pair(tuple<_Args1...>&, tuple<_Args2...>&,
167 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
171 template<typename _T1, typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
177 namespace std __attribute__ ((__visibility__ ("default")))
181 template<typename _Tp>
182 using __make_not_void
183 = typename conditional<is_void<_Tp>::value, __undefined, _Tp>::type;
185 template <typename Ptr>
186 struct pointer_traits {};
188 template<typename _Tp>
189 struct pointer_traits<_Tp*>
192 typedef _Tp* pointer;
194 typedef _Tp element_type;
196 static constexpr pointer
197 pointer_to(__make_not_void<element_type>& __r) noexcept
198 { return __builtin_addressof(__r); }
201 template<typename _Tp>
204 template<typename _Alloc>
205 struct allocator_traits;
207 template<typename _Tp>
208 struct allocator_traits<allocator<_Tp>>
210 using pointer = _Tp*;
213 template<typename _Alloc>
214 struct __alloc_traits
215 : std::allocator_traits<_Alloc>
217 typedef std::allocator_traits<_Alloc> _Base_type;
218 typedef typename _Base_type::pointer pointer;
221 template<class _CharT>
224 template<typename _CharT, typename _Traits = char_traits<_CharT>,
225 typename _Alloc = allocator<_CharT> >
228 typedef std::__alloc_traits<_Alloc> _Alloc_traits;
231 typedef typename _Alloc_traits::pointer pointer;
235 _CharT _M_local_buf[16];
240 return std::pointer_traits<pointer>::pointer_to(*_M_local_buf);
244 : _M_dataplus(_M_local_data())
249 typedef basic_string<char> string;
255 struct _Power2_rehash_policy
257 std::pair<bool, std::size_t>
258 _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
259 std::size_t __n_ins) noexcept
269 typedef __SIZE_TYPE__ size_t;