Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::dry_detail Namespace Reference

Classes

struct  inner_item
 Item type of a container returned by the operation of flat_map(): its Item_Type, or else its value_type. More...
 
struct  inner_item< C >
 Item type of an Aleph container returned by the operation of flat_map(). More...
 
struct  Modifying_Probe
 Operation that needs to modify the item it receives. More...
 
struct  Reading_Probe
 Operation that only reads the item and never throws. More...
 

Concepts

concept  MutablyTraversable
 The modifiable traversal of Container hands out T &.
 
concept  SetSearchable
 Container can be compared as a set: it has size(), a Key_Type and a search() that returns a pointer.
 
concept  FoldOperation
 op folds an accumulator Acc with an item T.
 
concept  FoldRightOperation
 op folds an item T with an accumulator Acc from the right.
 

Functions

template<class It >
void advance (It &it) noexcept(advance_is_noexcept< It >)
 Advance an iterator that is positioned on an item.
 
template<class It >
decltype(auto) current (It &it) noexcept(current_is_noexcept< It >)
 Current item of an iterator that is positioned on one.
 
template<class Acc , class Step >
void assign_fold (Acc &acc, Step &&step)
 Store in acc the result of a folding step step().
 
template<class Acc , class Op , class T >
void fold_left_step (Acc &acc, Op &op, const T &item)
 One step of a left fold: acc = op(acc, item).
 
template<class Acc , class Op , class T >
void fold_right_step (Acc &acc, Op &op, const T &item)
 One step of a right fold: acc = op(item, acc).
 

Variables

template<class Container , class T >
constexpr bool const_traversal_is_noexcept
 The constant traversal of Container cannot throw by itself.
 
template<class Container , class T >
constexpr bool mutable_traversal_is_noexcept
 The modifiable traversal of Container cannot throw by itself.
 
template<class It >
constexpr bool advance_is_noexcept
 Advancing an iterator positioned on an item cannot throw.
 
template<class It >
constexpr bool current_is_noexcept
 Reading the current item of an iterator positioned on one cannot throw.
 

Function Documentation

◆ advance()

template<class It >
void Aleph::dry_detail::advance ( It &  it)
noexcept

Advance an iterator that is positioned on an item.

Uses next_ne() when the iterator has it: the caller has already checked has_curr(), so the check of next() is redundant.

Parameters
[in,out]ititerator positioned on an item.
Exceptions
anythingthat next() throws, if the iterator has no next_ne().

Definition at line 214 of file ah-dry.H.

Referenced by EqualSequenceMethod< Container >::equal_to(), EqualSortedMethod< Container >::equal_to(), GenericTraverse< Container >::traverse(), and GenericTraverse< Container >::traverse().

◆ assign_fold()

template<class Acc , class Step >
void Aleph::dry_detail::assign_fold ( Acc &  acc,
Step &&  step 
)

Store in acc the result of a folding step step().

If the step returns a reference, which may be to acc itself, the result is moved out first, so that acc is never assigned from itself.

Parameters
[in,out]accthe accumulator.
[in]stepcallable that runs the folding step.
Exceptions
anythingthat step or the assignment of Acc throws.

Definition at line 299 of file ah-dry.H.

References Aleph::next().

Referenced by fold_left_step(), and fold_right_step().

◆ current()

template<class It >
decltype(auto) Aleph::dry_detail::current ( It &  it)
noexcept

Current item of an iterator that is positioned on one.

Uses get_curr_ne() when the iterator has it: the caller has already checked has_curr().

Parameters
[in]ititerator positioned on an item.
Returns
what get_curr_ne(), or else get_curr(), returns.
Exceptions
anythingthat get_curr() throws, if the iterator has no get_curr_ne().

Definition at line 233 of file ah-dry.H.

Referenced by EqualSequenceMethod< Container >::equal_to(), EqualSortedMethod< Container >::equal_to(), GenericTraverse< Container >::traverse(), and GenericTraverse< Container >::traverse().

◆ fold_left_step()

template<class Acc , class Op , class T >
void Aleph::dry_detail::fold_left_step ( Acc &  acc,
Op &  op,
const T &  item 
)

One step of a left fold: acc = op(acc, item).

The accumulator is moved into op when op accepts an rvalue, so that folding into a container costs O(1) per step instead of a copy of the whole accumulator, as std::accumulate does since C++20.

Parameters
[in,out]accthe accumulator.
[in]opthe folding operation.
[in]itemthe current item.
Exceptions
anythingthat op or the assignment of Acc throws.

Definition at line 322 of file ah-dry.H.

References assign_fold().

Referenced by FunctionalMethods< Container, T >::foldl(), and FunctionalMethods< Container, T >::reduce().

◆ fold_right_step()

template<class Acc , class Op , class T >
void Aleph::dry_detail::fold_right_step ( Acc &  acc,
Op &  op,
const T &  item 
)

One step of a right fold: acc = op(item, acc).

Parameters
[in,out]accthe accumulator.
[in]opthe folding operation.
[in]itemthe current item.
Exceptions
anythingthat op or the assignment of Acc throws.

Definition at line 338 of file ah-dry.H.

References assign_fold().

Referenced by FunctionalMethods< Container, T >::foldr().

Variable Documentation

◆ advance_is_noexcept

template<class It >
constexpr bool Aleph::dry_detail::advance_is_noexcept
inlineconstexpr
Initial value:
= []
{
if constexpr (requires(It & it) { it.next_ne(); })
return noexcept(std::declval<It &>().next_ne());
else
return noexcept(std::declval<It &>().next());
}()

Advancing an iterator positioned on an item cannot throw.

Definition at line 185 of file ah-dry.H.

◆ const_traversal_is_noexcept

template<class Container , class T >
constexpr bool Aleph::dry_detail::const_traversal_is_noexcept
inlineconstexpr
Initial value:
=
noexcept(std::declval<const Container &>().traverse(std::declval<Reading_Probe<T> &>()))

The constant traversal of Container cannot throw by itself.

True if traverse() on a constant container is noexcept when its operation is. A container whose traverse() has no noexcept specification is taken as possibly throwing.

Template Parameters
Containerthe CRTP-derived container.
Titem type.

Definition at line 169 of file ah-dry.H.

◆ current_is_noexcept

template<class It >
constexpr bool Aleph::dry_detail::current_is_noexcept
inlineconstexpr
Initial value:
= []
{
if constexpr (requires(It & it) { it.get_curr_ne(); })
return noexcept(std::declval<It &>().get_curr_ne());
else
return noexcept(std::declval<It &>().get_curr());
}()

Reading the current item of an iterator positioned on one cannot throw.

Definition at line 196 of file ah-dry.H.

◆ mutable_traversal_is_noexcept

template<class Container , class T >
constexpr bool Aleph::dry_detail::mutable_traversal_is_noexcept
inlineconstexpr
Initial value:
=
noexcept(std::declval<Container &>().traverse(std::declval<Modifying_Probe<T> &>()))

The modifiable traversal of Container cannot throw by itself.

Only meaningful when MutablyTraversable<Container, T> holds.

Template Parameters
Containerthe CRTP-derived container.
Titem type.

Definition at line 180 of file ah-dry.H.