Skip to content

Commit

Permalink
Apply P0663R0 PR for 318: common_iterator::operator-> does not specif…
Browse files Browse the repository at this point in the history
…y its return type

Fixes #318.
  • Loading branch information
CaseyCarter committed Jul 18, 2017
1 parent 890fce8 commit 6d91cac
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions iterators.tex
Expand Up @@ -4029,35 +4029,40 @@
\indexlibrary{\idxcode{operator->}!\idxcode{common_iterator}}%
\indexlibrary{\idxcode{common_iterator}!\idxcode{operator->}}%
\begin{itemdecl}
@\seebelow@ operator->() const requires Readable<I>;
decltype(auto) operator->() const requires Readable<I>;
\end{itemdecl}

\begin{itemdescr}
\pnum
\requires \tcode{!is_sentinel}

\pnum
\effects Given an object \tcode{i} of type \tcode{I}
\effects Equivalent to:
\begin{itemize}
\item if \tcode{I} is a pointer type or if the expression
\tcode{i.operator->()} is well-formed, this function returns
\tcode{iter}.
\item Otherwise, if the expression \tcode{*iter} is a glvalue, this function
is equivalent to \tcode{return addressof(*iter);}
\item Otherwise, this function returns a proxy object of an unspecified type
equivalent to the following:
\begin{codeblock}
class proxy { // \expos
value_type_t<I> keep_;
proxy(reference_t<I>&& x)
: keep_(std::move(x)) {}
public:
const value_type_t<I>* operator->() const {
return addressof(keep_);
}
};
\end{codeblock}
that is initialized with \tcode{*iter}.
\item
If \tcode{I} is a pointer type or if the expression \tcode{i.operator->()} is
well-formed, \tcode{return iter;}

\item
Otherwise, if the expression \tcode{*iter} is a glvalue:
\begin{codeblock}
auto&& tmp = *iter;
return addressof(tmp);
\end{codeblock}

\item
Otherwise, \tcode{return proxy(*iter);} where proxy is the exposition-only class:
\begin{codeblock}
class proxy { // \expos
value_type_t<I> keep_;
proxy(reference_t<I>&& x)
: keep_(std::move(x)) {}
public:
const value_type_t<I>* operator->() const {
return addressof(keep_);
}
};
\end{codeblock}
\end{itemize}
\end{itemdescr}

Expand Down

0 comments on commit 6d91cac

Please sign in to comment.