[libcxx-commits] [PATCH] D140714: [libc++][NFC] Rename basic_istream_view::__iterator to __basic_istream_view_iterator
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 12 09:30:12 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG187d2cdafb49: [libc++][NFC] Rename basic_istream_view::__iterator to… (authored by philnik).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140714/new/
https://reviews.llvm.org/D140714
Files:
libcxx/include/__ranges/istream_view.h
Index: libcxx/include/__ranges/istream_view.h
===================================================================
--- libcxx/include/__ranges/istream_view.h
+++ libcxx/include/__ranges/istream_view.h
@@ -36,9 +36,19 @@
template <class _Val, class _CharT, class _Traits>
concept __stream_extractable = requires(basic_istream<_CharT, _Traits>& __is, _Val& __t) { __is >> __t; };
+template <movable _Val, class _CharT, class _Traits>
+ requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits>
+class __basic_istream_view_iterator;
+
template <movable _Val, class _CharT, class _Traits = char_traits<_CharT>>
requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits>
class basic_istream_view : public view_interface<basic_istream_view<_Val, _CharT, _Traits>> {
+ using __iterator = __basic_istream_view_iterator<_Val, _CharT, _Traits>;
+
+ template <movable _ValueType, class _CharType, class _TraitsType>
+ requires default_initializable<_ValueType> && __stream_extractable<_ValueType, _CharType, _TraitsType>
+ friend class __basic_istream_view_iterator;
+
public:
_LIBCPP_HIDE_FROM_ABI constexpr explicit basic_istream_view(basic_istream<_CharT, _Traits>& __stream)
: __stream_(std::addressof(__stream)) {}
@@ -51,30 +61,29 @@
_LIBCPP_HIDE_FROM_ABI constexpr default_sentinel_t end() const noexcept { return default_sentinel; }
private:
- class __iterator;
-
basic_istream<_CharT, _Traits>* __stream_;
_LIBCPP_NO_UNIQUE_ADDRESS _Val __value_ = _Val();
};
template <movable _Val, class _CharT, class _Traits>
requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits>
-class basic_istream_view<_Val, _CharT, _Traits>::__iterator {
+class __basic_istream_view_iterator {
public:
using iterator_concept = input_iterator_tag;
using difference_type = ptrdiff_t;
using value_type = _Val;
- _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(basic_istream_view& __parent) noexcept
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __basic_istream_view_iterator(
+ basic_istream_view<_Val, _CharT, _Traits>& __parent) noexcept
: __parent_(std::addressof(__parent)) {}
- __iterator(const __iterator&) = delete;
- _LIBCPP_HIDE_FROM_ABI __iterator(__iterator&&) = default;
+ __basic_istream_view_iterator(const __basic_istream_view_iterator&) = delete;
+ _LIBCPP_HIDE_FROM_ABI __basic_istream_view_iterator(__basic_istream_view_iterator&&) = default;
- __iterator& operator=(const __iterator&) = delete;
- _LIBCPP_HIDE_FROM_ABI __iterator& operator=(__iterator&&) = default;
+ __basic_istream_view_iterator& operator=(const __basic_istream_view_iterator&) = delete;
+ _LIBCPP_HIDE_FROM_ABI __basic_istream_view_iterator& operator=(__basic_istream_view_iterator&&) = default;
- _LIBCPP_HIDE_FROM_ABI __iterator& operator++() {
+ _LIBCPP_HIDE_FROM_ABI __basic_istream_view_iterator& operator++() {
*__parent_->__stream_ >> __parent_->__value_;
return *this;
}
@@ -83,12 +92,12 @@
_LIBCPP_HIDE_FROM_ABI _Val& operator*() const { return __parent_->__value_; }
- _LIBCPP_HIDE_FROM_ABI friend bool operator==(const __iterator& __x, default_sentinel_t) {
+ _LIBCPP_HIDE_FROM_ABI friend bool operator==(const __basic_istream_view_iterator& __x, default_sentinel_t) {
return !*__x.__get_parent_stream();
}
private:
- basic_istream_view* __parent_;
+ basic_istream_view<_Val, _CharT, _Traits>* __parent_;
_LIBCPP_HIDE_FROM_ABI constexpr basic_istream<_CharT, _Traits>* __get_parent_stream() const {
return __parent_->__stream_;
@@ -98,10 +107,10 @@
template <class _Val>
using istream_view = basic_istream_view<_Val, char>;
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class _Val>
using wistream_view = basic_istream_view<_Val, wchar_t>;
-#endif
+# endif
namespace views {
namespace __istream {
@@ -127,7 +136,7 @@
inline namespace __cpo {
template <class _Tp>
- inline constexpr auto istream = __istream::__fn<_Tp>{};
+inline constexpr auto istream = __istream::__fn<_Tp>{};
} // namespace __cpo
} // namespace views
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140714.488692.patch
Type: text/x-patch
Size: 4244 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230112/996a4d54/attachment.bin>
More information about the libcxx-commits
mailing list