@@ -1106,9 +1106,10 @@ namespace ranges {
11061106 _EXPORT_STD template <class _Container , input_range _Rng, class ... _Types>
11071107 requires (!view<_Container>)
11081108 _NODISCARD constexpr _Container to(_Rng&& _Range, _Types&&... _Args) {
1109- static_assert (!is_const_v<_Container>, " C must not be const. ([range.utility.conv.to])" );
1110- static_assert (!is_volatile_v<_Container>, " C must not be volatile. ([range.utility.conv.to])" );
1111- static_assert (is_class_v<_Container>, " C must be a class type. ([range.utility.conv.to])" );
1109+ static_assert (!is_const_v<_Container>, " C must not be const. (N5014 [range.utility.conv.to]/1)" );
1110+ static_assert (!is_volatile_v<_Container>, " C must not be volatile. (N5014 [range.utility.conv.to]/1)" );
1111+ static_assert (is_class_v<_Container> || is_union_v<_Container>,
1112+ " C must be a class type. (N5014 [range.utility.conv.to]/1)" );
11121113 if constexpr (_Ref_converts<_Rng, _Container>) {
11131114 if constexpr (constructible_from<_Container, _Rng, _Types...>) {
11141115 return _Container (_STD forward<_Rng>(_Range), _STD forward<_Types>(_Args)...);
@@ -1142,7 +1143,7 @@ namespace ranges {
11421143 } else {
11431144 static_assert (false , " ranges::to requires the result to be constructible from the source range, either "
11441145 " by using a suitable constructor, or by inserting each element of the range into "
1145- " the default-constructed object. (N4981 [range.utility.conv.to]/2.1.5)" );
1146+ " the default-constructed object. (N5014 [range.utility.conv.to]/2.1.5)" );
11461147 }
11471148 } else if constexpr (input_range<range_reference_t <_Rng>>) {
11481149 const auto _Xform = [](auto && _Elem) _STATIC_LAMBDA {
@@ -1153,15 +1154,15 @@ namespace ranges {
11531154 static_assert (false ,
11541155 " ranges::to requires the elements of the source range to be either implicitly convertible to the "
11551156 " elements of the destination container, or be ranges themselves for ranges::to to be applied "
1156- " recursively. (N4981 [range.utility.conv.to]/2.3)" );
1157+ " recursively. (N5014 [range.utility.conv.to]/2.3)" );
11571158 }
11581159 }
11591160
11601161 template <class _Container >
11611162 struct _To_class_fn {
11621163 _STL_INTERNAL_STATIC_ASSERT (!is_const_v<_Container>);
11631164 _STL_INTERNAL_STATIC_ASSERT (!is_volatile_v<_Container>);
1164- _STL_INTERNAL_STATIC_ASSERT (is_class_v<_Container>);
1165+ _STL_INTERNAL_STATIC_ASSERT (is_class_v<_Container> || is_union_v<_Container> );
11651166 _STL_INTERNAL_STATIC_ASSERT (!view<_Container>);
11661167
11671168 template <input_range _Rng, class ... _Types>
@@ -1176,9 +1177,10 @@ namespace ranges {
11761177 _EXPORT_STD template <class _Container , class ... _Types>
11771178 requires (!view<_Container>)
11781179 _NODISCARD constexpr auto to(_Types&&... _Args) {
1179- static_assert (!is_const_v<_Container>, " C must not be const. ([range.utility.conv.adaptors])" );
1180- static_assert (!is_volatile_v<_Container>, " C must not be volatile. ([range.utility.conv.adaptors])" );
1181- static_assert (is_class_v<_Container>, " C must be a class type. ([range.utility.conv.adaptors])" );
1180+ static_assert (!is_const_v<_Container>, " C must not be const. (N5014 [range.utility.conv.adaptors]/1)" );
1181+ static_assert (!is_volatile_v<_Container>, " C must not be volatile. (N5014 [range.utility.conv.adaptors]/1)" );
1182+ static_assert (is_class_v<_Container> || is_union_v<_Container>,
1183+ " C must be a class type. (N5014 [range.utility.conv.adaptors]/1)" );
11821184 return _Range_closure<_To_class_fn<_Container>, decay_t <_Types>...>{_STD forward<_Types>(_Args)...};
11831185 }
11841186
0 commit comments