52 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: no-localization10// UNSUPPORTED: c++03, c++11, c++14, c++1711 12// Val& operator*() const;13 14#include <cassert>15#include <ranges>16#include <sstream>17 18#include "test_macros.h"19#include "../utils.h"20 21template <class CharT>22void test() {23 // operator* should return correct value24 {25 auto iss = make_string_stream<CharT>("1 2 345 ");26 std::ranges::basic_istream_view<int, CharT> isv{iss};27 auto it = isv.begin();28 std::same_as<int&> decltype(auto) v1 = *it;29 assert(v1 == 1);30 }31 32 // operator* should return the same reference to the value stored in the view33 {34 auto iss = make_string_stream<CharT>("1 2 345 ");35 std::ranges::basic_istream_view<int, CharT> isv{iss};36 using Iter = std::ranges::iterator_t<decltype(isv)>;37 38 Iter it1{isv};39 Iter it2{isv};40 assert(&*it1 == &*it2);41 }42}43 44int main(int, char**) {45 test<char>();46#ifndef TEST_HAS_NO_WIDE_CHARACTERS47 test<wchar_t>();48#endif49 50 return 0;51}52