File tree Expand file tree Collapse file tree 2 files changed +36
-4
lines changed
tests/std/tests/P0980R1_constexpr_strings Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -2317,9 +2317,11 @@ public:
2317
2317
_Mypair._Myval2._Mysize = _New_size;
2318
2318
}
2319
2319
2320
- auto _Arg_ptr = _Mypair._Myval2._Myptr();
2321
- auto _Arg_size = _New_size;
2322
- const auto _Result_size = _STD move(_Op)(_Arg_ptr, _Arg_size);
2320
+ auto _Arg_ptr = _Mypair._Myval2._Myptr();
2321
+ auto _Arg_size = _New_size;
2322
+ const auto _Result_size = _STD move(_Op)(_Arg_ptr, _Arg_size);
2323
+ static_assert(_Integer_like<decltype(_Result_size)>, "the return type of the operation must be integer-like");
2324
+
2323
2325
const auto _Result_as_size_type = static_cast<size_type>(_Result_size);
2324
2326
#if _ITERATOR_DEBUG_LEVEL != 0
2325
2327
_STL_VERIFY(_Result_size >= 0, "the returned size can't be smaller than 0");
Original file line number Diff line number Diff line change 17
17
#include < type_traits>
18
18
#include < utility>
19
19
20
+ #if _HAS_CXX20
21
+ #include < ranges> // for integer-class types
22
+ #endif // _HAS_CXX20
23
+
20
24
using namespace std ;
21
25
22
26
constexpr auto literal_input = " Hello fluffy kittens" ;
@@ -2226,15 +2230,41 @@ constexpr void test_all() {
2226
2230
}
2227
2231
2228
2232
#if _HAS_CXX23
2233
+ template <class I >
2229
2234
void test_gh_2524 () { // COMPILE-ONLY
2230
2235
// GH-2524 resize_and_overwrite generates warning C4018 when Operation returns int
2231
2236
string s;
2232
2237
s.resize_and_overwrite (1 , [](char * buffer, size_t ) {
2233
2238
*buffer = ' x' ;
2234
- int i = 1 ;
2239
+ I i = 1 ;
2235
2240
return i;
2236
2241
});
2237
2242
}
2243
+
2244
+ void test_gh_2524_all () { // COMPILE-ONLY
2245
+ test_gh_2524<signed char >();
2246
+ test_gh_2524<short >();
2247
+ test_gh_2524<int >();
2248
+ test_gh_2524<long >();
2249
+ test_gh_2524<long long >();
2250
+
2251
+ test_gh_2524<unsigned char >();
2252
+ test_gh_2524<unsigned short >();
2253
+ test_gh_2524<unsigned int >();
2254
+ test_gh_2524<unsigned long >();
2255
+ test_gh_2524<unsigned long long >();
2256
+
2257
+ test_gh_2524<char >();
2258
+ #ifdef __cpp_char8_t
2259
+ test_gh_2524<char8_t >();
2260
+ #endif // defined(__cpp_char8_t)
2261
+ test_gh_2524<char16_t >();
2262
+ test_gh_2524<char32_t >();
2263
+ test_gh_2524<wchar_t >();
2264
+
2265
+ test_gh_2524<_Signed128>();
2266
+ test_gh_2524<_Unsigned128>();
2267
+ }
2238
2268
#endif // _HAS_CXX23
2239
2269
2240
2270
int main () {
You can’t perform that action at this time.
0 commit comments