Skip to content

Commit

Permalink
Added copy constructor and copy assignment operator to normal_iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
slavenf committed Jun 14, 2024
1 parent 595764a commit 052c541
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion include/sfl/private.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,25 @@ class normal_iterator
: it_()
{}

// Copy constructor and converting constructor (from iterator to const_iterator)
// Copy constructor
normal_iterator(const normal_iterator& other) noexcept
: it_(other.it_)
{}

// Converting constructor (from iterator to const_iterator)
template <typename OtherIterator,
sfl::dtl::enable_if_t<std::is_convertible<OtherIterator, Iterator>::value>* = nullptr>
normal_iterator(const normal_iterator<OtherIterator, Container>& other) noexcept
: it_(other.it_)
{}

// Copy assignment operator
normal_iterator& operator=(const normal_iterator& other) noexcept
{
it_ = other.it_;
return *this;
}

SFL_NODISCARD
reference operator*() const noexcept
{
Expand Down

0 comments on commit 052c541

Please sign in to comment.