Clingo
|
Helper to update a vector of elements. More...
#include <optional.hh>
Public Types | |
using | ValueType = T |
The value type. | |
using | Span = std::span< ValueType const > |
A span of values. | |
using | Array = Util::immutable_array< ValueType > |
An array of values. | |
using | Vector = std::vector< ValueType > |
A vector of values. | |
using | Source = std::conditional_t< UseSpan, Span, Array const & > |
The (reference to the) source values. | |
using | Iterator = std::conditional_t< UseSpan, typename Span::iterator, typename Array::const_iterator > |
A constant iterator to the source values. | |
using | Result = std::conditional_t< UseSpan, Vector, Array > |
The result values. | |
Public Member Functions | |
ResultVec (Source source) | |
Construct a result vec to track changes to the given source. | |
auto | current () const -> ValueType const & |
Get current element. | |
void | keep () |
Keep the current element. | |
void | keep_all () |
Keep all elements. | |
void | remove () |
Remove the current element. | |
template<class... Args> | |
void | replace (Args &&...args) |
Replace the current element. | |
void | update (std::optional< ValueType > value) |
Update the current alement given the optional value. | |
template<class... Args> | |
void | append (Args &&...args) |
Append fresh elements. | |
template<class It > | |
void | extend (It begin, It end) |
Append fresh elements. | |
auto | value () const &-> Span |
Get a const reference to the current vector. | |
auto | value () &&-> Result |
Move out the new vector or return a copy of the old one. | |
auto | has_value () const -> bool |
Check if the old vector has been updated. | |
auto | as_optional () &-> std::optional< Vector > & |
Return a reference to the updated vector if there was a change. | |
auto | as_optional () &&-> std::optional< Vector > |
Move out the updated vector. | |
auto | operator* () const &-> Span |
Get a const reference to the current vector. | |
auto | operator* () &&-> Result |
Move out the new vector or return a copy of the old one. | |
operator bool () const | |
Check if the old vector has been updated. | |
auto | complete () const |
Check if all elements have been processed. | |
Helper to update a vector of elements.
Flag UseSpan can be set to false when using an immutable_array. This uses the efficient copying of the array in case there was no change.
|
inline |
Get a const reference to the current vector.
This returns a reference to the old vector if it does not have a new one.
|
inline |
Get a const reference to the current vector.
This returns a reference to the old vector if it does not have a new one.