requires std::is_object_v<T>
Some range adaptors such as ranges::join_view and ranges::lazy_split_view conditionally store value (e.g. an iterator) which is specified in terms of an exposition-only class template non-propagating-cache
.
The wrapper behaves exactly like std::optional<T>, except that:
The wrapper encapsulates a cache containing a value. Clearing cache is an operation equivalent to resetting a contained value. Such operation is performed when copying or moving a wrapper.
[edit] Template parameters T - the type of the contained value, must be an object type [edit] Member functions Copy and move constructorsconstexpr /*non-propagating-cache*/
( const /*non-propagating-cache*/& ) noexcept {}
constexpr /*non-propagating-cache*/
( /*non-propagating-cache*/&& other ) noexcept { other.reset(); }
1) The copy constructor has no effect.
2) The move constructor clears the cache of other.
Copy and move assignment operators constexpr /*non-propagating-cache*/& operator=( const /*non-propagating-cache*/& other ) noexcept
{
if (std::addressof(other) != this)
reset();
return *this;
operator=( /*non-propagating-cache*/&& other ) noexcept
{
reset();
other.reset();
return *this;
1) The copy assignment operator clears the cache of *this.
2) The move assignment operator clears caches of both *this and other.
non-propagating-cache<T>::emplace-deref
template< class I >
constexpr T& /*emplace-deref*/( const I& i );
Initializes the contained value by direct-initializing (but not direct-list-initializing) with *i. If *this already contains a value before the call, reset() is called.
Returns a reference to the new contained value.
The program is ill-formed unless the declaration T t(*i); is well-formed for some invented variable t. If *i is a prvalue of possibly cv-qualified T
, then it is not required to be movable.
optional
object
std::optional<T>
) [edit] destroys the contained value, if there is one
std::optional<T>
) [edit] assigns contents
std::optional<T>
) [edit] Observers accesses the contained value
std::optional<T>
) [edit] checks whether the object contains a value
std::optional<T>
) [edit] Modifiers destroys any contained value
std::optional<T>
) [edit] constructs the contained value in-place
std::optional<T>
) [edit] [edit] Notes
non-propagating-cache
is used in implementations to cache the result of begin() to provide an amortized constant time complexity of the method.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4