Skip to content

Commit e73c958

Browse files
committed
clarify assert information and correct the test
1 parent ec5c94a commit e73c958

File tree

2 files changed

+12
-20
lines changed
  • libcxx

2 files changed

+12
-20
lines changed

libcxx/include/__ranges/to.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ template <class _Container, input_range _Range, class... _Args>
8383
static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const");
8484
static_assert(
8585
!is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile");
86-
static_assert(is_class_v<_Container> || is_union_v<_Container>, "The target must be a class type");
86+
static_assert(is_class_v<_Container> || is_union_v<_Container>, "The target must be a class type or union type");
8787
// First see if the non-recursive case applies -- the conversion target is either:
8888
// - a range with a convertible value type;
8989
// - a non-range type which might support being created from the input argument(s) (e.g. an `optional`).
@@ -210,7 +210,7 @@ template <class _Container, class... _Args>
210210
static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const");
211211
static_assert(
212212
!is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile");
213-
static_assert(is_class_v<_Container> || is_union_v<_Container>, "The target must be a class type");
213+
static_assert(is_class_v<_Container> || is_union_v<_Container>, "The target must be a class type or union type");
214214
auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail) static
215215
requires requires { //
216216
/**/ ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...);

libcxx/test/libcxx/ranges/range.utility/range.utility.conv/to.verify.cpp

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ void test() {
2121
using member_func_ptr = decltype(&C::f);
2222
using member_ptr = decltype(&C::member);
2323
using func_ptr = decltype(&ff);
24-
using func_t = decltype(ff);
2524

2625
struct R {
2726
int* begin() const { return nullptr; };
@@ -30,7 +29,6 @@ void test() {
3029
operator int() const { return 0; }
3130
operator int*() const { return nullptr; }
3231
operator func_ptr() const { return nullptr; }
33-
operator void() const {}
3432
operator member_func_ptr() const { return nullptr; }
3533
operator member_ptr() const { return nullptr; }
3634
operator color() const { return color::red; }
@@ -49,31 +47,25 @@ void test() {
4947
std::ranges::to<
5048
func_ptr>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
5149

52-
(void)std::ranges::to<void>(
53-
R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
54-
(void)(R{} | std::ranges::to<
55-
void>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
5650
(void)std::ranges::to<member_ptr>(
5751
R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
5852
(void)(R{} |
5953
std::ranges::to<
6054
member_ptr>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
61-
(void)std::ranges::to<member_func_ptr>(
55+
56+
(void)std::ranges::to<func_t>(
6257
R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
63-
(void)(R{} |
64-
std::ranges::to<
65-
member_func_ptr>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
66-
(void)std::ranges::to<func_ptr>(
58+
(void)(R{} | std::ranges::to<
59+
func_t>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
60+
61+
(void)std::ranges::to<void>(
6762
R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
68-
(void)(R{} |
69-
std::ranges::to<
70-
func_ptr>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
63+
(void)(R{} | std::ranges::to<
64+
void>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
65+
//expected-error-re@*:* {{static assertion failed{{.*}}ranges::to: unable to convert to the given container type.}}
66+
7167
(void)std::ranges::to<color>(
7268
R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
7369
(void)(R{} | std::ranges::to<
7470
color>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
75-
(void)std::ranges::to<func_t>(
76-
R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
77-
(void)(R{} | std::ranges::to<
78-
func_t>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
7971
}

0 commit comments

Comments
 (0)