Skip to content

Commit

Permalink
Implement P0738
Browse files Browse the repository at this point in the history
This addresses #35
  • Loading branch information
miscco committed Nov 2, 2019
1 parent b9eb320 commit 95bfc03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion stl/inc/iterator
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,23 @@ public:
using traits_type = _Traits;
using istream_type = basic_istream<_Elem, _Traits>;

static_assert(conjunction_v<is_default_constructible<_Ty>, is_copy_constructible<_Ty>, is_copy_assignable<_Ty>>,
"The type T shall meet the Cpp17DefaultConstructible, Cpp17CopyConstructible, and Cpp17CopyAssignable "
"requirements. (Enabled unconditionally from CXX20)");

constexpr istream_iterator() : _Myistr(nullptr), _Myval() {}

istream_iterator(istream_type& _Istr) : _Myistr(_STD addressof(_Istr)) {
istream_iterator(istream_type& _Istr) : _Myistr(_STD addressof(_Istr)), _Myval() {
_Getval();
}

_NODISCARD const _Ty& operator*() const {
_STL_ASSERT(_Myistr, "The stored stream pointer in_stream must be non null");
return _Myval;
}

_NODISCARD const _Ty* operator->() const {
_STL_ASSERT(_Myistr, "The stored stream pointer in_stream must be non null");
return _STD addressof(_Myval);
}

Expand All @@ -164,6 +170,7 @@ public:

protected:
void _Getval() { // get a _Ty value if possible
_STL_ASSERT(_Myistr, "The stored stream pointer in_stream must be non null");
if (_Myistr && !(*_Myistr >> _Myval)) {
_Myistr = nullptr;
}
Expand Down
2 changes: 2 additions & 0 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// P0646R1 list/forward_list remove()/remove_if()/unique() Return size_type
// P0653R2 to_address()
// P0655R1 visit<R>()
// P0738R2 istream_iterator Cleanup. The minstrel know it as "I Stream, You Stream, We All Stream for istream_iterator"
// P0758R1 is_nothrow_convertible
// P0768R1 Library Support For The Spaceship Comparison Operator <=>
// (partially implemented)
Expand Down Expand Up @@ -158,6 +159,7 @@
// P0548R1 Tweaking common_type And duration
// P0558R1 Resolving atomic<T> Named Base Class Inconsistencies
// P0599R1 noexcept hash
// P0738R2 istream_iterator Cleanup
// P0771R1 noexcept For std::function's Move Constructor
// P0777R1 Avoiding Unnecessary decay
// P0809R0 Comparing Unordered Containers
Expand Down

0 comments on commit 95bfc03

Please sign in to comment.