[libcxx-commits] [libcxx] Fix the LWG 3568 test for basic_istream_view (PR #215589)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 11 08:58:47 PDT 2026
================
@@ -39,10 +39,8 @@ void test() {
// LWG 3568. basic_istream_view needs to initialize value_
{
- auto iss = make_string_stream<CharT>("");
- std::ranges::basic_istream_view<int, CharT> isv{iss};
- auto iter = isv.begin();
- assert(*iter == 0);
+ static auto fn_local_iss = make_string_stream<CharT>("");
+ [[maybe_unused]] constexpr auto isv = std::views::istream<int>(fn_local_iss);
----------------
frederick-vs-ja wrote:
Thanks! I used to think that we can't verify the zero-initialized value. But I guess we can verify it now with the following class.
```C++
struct NoopExtraction {
int n_; // intentionally doesn't have default member initializer
template <class CharT, class Traits>
std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& is, const NoopExtraction&) {
return is; // intentionally doesn't modify the NoopExtraction object
}
};
```
We may assert that the member `n_` is `0` after extraction.
https://github.com/llvm/llvm-project/pull/215589
More information about the libcxx-commits
mailing list