Skip to content

Commit 7515cdb

Browse files
committed
[libc++][ranges]add static_assert for ranges::to
1 parent e1382b3 commit 7515cdb

File tree

1 file changed

+4
-2
lines changed
  • libcxx/include/__ranges

1 file changed

+4
-2
lines changed

libcxx/include/__ranges/to.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <__type_traits/add_pointer.h>
2929
#include <__type_traits/is_const.h>
3030
#include <__type_traits/is_volatile.h>
31+
#include <__type_traits/is_class.h>
32+
#include <__type_traits/is_union.h>
3133
#include <__type_traits/type_identity.h>
3234
#include <__utility/declval.h>
3335
#include <__utility/forward.h>
@@ -81,7 +83,7 @@ template <class _Container, input_range _Range, class... _Args>
8183
static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const");
8284
static_assert(
8385
!is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile");
84-
86+
static_assert(is_class_v<_Container>||is_union_v<_Container>, "The target must be a class type");
8587
// First see if the non-recursive case applies -- the conversion target is either:
8688
// - a range with a convertible value type;
8789
// - a non-range type which might support being created from the input argument(s) (e.g. an `optional`).
@@ -208,7 +210,7 @@ template <class _Container, class... _Args>
208210
static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const");
209211
static_assert(
210212
!is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile");
211-
213+
static_assert(is_class_v<_Container>||is_union_v<_Container>, "The target must be a class type");
212214
auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail) static
213215
requires requires { //
214216
/**/ ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...);

0 commit comments

Comments
 (0)