A missing 'constexpr' in the non-forward (and non-sized) branch of our
recently implemented vector from_range ctor was causing this valid example
to be rejected with a cryptic error.
PR libstdc++/119282
libstdc++-v3/ChangeLog:
* include/bits/stl_vector.h (vector::vector(from_range_t)): Add
missing 'constexpr' to local class _Clear.
* testsuite/std/ranges/conv/1.cc (test_pr119282): New test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
// but will not destroy elements. This RAII type destroys them.
struct _Clear
{
- ~_Clear() { if (_M_this) _M_this->clear(); }
+ constexpr ~_Clear() { if (_M_this) _M_this->clear(); }
vector* _M_this;
} __guard{this};
auto str = adaptor(" ");
}
+constexpr bool
+test_pr119282()
+{
+ // PR libstdc++/119282
+ auto v = std::array{1, 2, 3}
+ | std::views::transform([](auto x) { return std::array{x}; })
+ | std::views::join
+ | std::ranges::to<std::vector>();
+ VERIFY( std::ranges::size(v) == 3 );
+ return true;
+}
+
int main()
{
test_p1206r7_examples();
test_constexpr();
test_sfinae();
test_composition();
+ static_assert(test_pr119282());
}