TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
tuple_tools.hpp
#include "./macros.hpp"
#include <cstddef>
#include <ostream>
#include <tuple>
#include <type_traits>
#include <utility>

Detailed Description

Generic tuple manipulation tools.

Definition in file tuple_tools.hpp.

Go to the source code of this file.

Typedefs

template<int N, int... Is>
using triqs::tuple::complement_sequence = typename complement_sequence_impl<N, all_indices<Is...>>::type
 Index sequence containing all integers of \( [0, N] \) that are not in Is....
template<typename T, int... Is>
using triqs::tuple::filter_out_t = std::decay_t<decltype(filter_out<Is...>(std::declval<T>()))>
 Result type of filter_out() for tuple type T dropping positions Is....
template<typename T, size_t... Is>
using triqs::tuple::filter_t = std::tuple<std::tuple_element_t<Is, std::decay_t<T>>...>
 Tuple type made of the elements at the given positions of given tuple type T.

Functions

template<typename F, typename T>
decltype(auto) triqs::tuple::apply (F &&f, T &&t)
 Call a function with the elements of a tuple as its arguments.
template<typename C, typename T>
decltype(auto) triqs::tuple::apply_construct (T &&t)
 Brace-construct an object from the elements of a tuple.
template<typename C, typename T>
decltype(auto) triqs::tuple::apply_construct_parenthesis (T &&t)
 Parenthesis-construct an object from the elements of a tuple.
template<typename F>
auto triqs::tuple::called_on_tuple (F &&f)
 Wrap a callable so that it can be invoked with a single tuple argument.
template<size_t... Is, typename T>
filter_t< T, Is... > triqs::tuple::filter (T &&t)
 Keep only the elements of a tuple at the given positions.
template<size_t... Is, typename T>
filter_t< T, Is... > triqs::tuple::filter (T &&t, std::index_sequence< Is... >)
 Keep only the elements of a tuple at the given positions (as an index-sequence).
template<int... Is, typename T>
decltype(auto) triqs::tuple::filter_out (T &&t)
 Drop the elements of a tuple at the given positions.
template<typename F, typename T, typename R>
decltype(auto) triqs::tuple::fold (F &&f, T &&t, R &&r)
 Left-fold a callable over the elements of a tuple.
template<typename F, typename T0, typename T1, typename R>
decltype(auto) triqs::tuple::fold (F &&f, T0 &&t1, T1 &&t2, R &&r)
 Left-fold a callable over the elements of two equally-sized tuples.
template<typename T, typename F>
void triqs::tuple::for_each (T &&t, F &&f)
 Apply a callable to every element of a tuple, in order.
template<typename T, typename F>
void triqs::tuple::for_each_enumerate (T &&t, F &&f)
 Apply a callable to every (index, element) pair of a tuple.
template<typename F, typename... Ts>
void triqs::tuple::for_each_zip (F &&f, Ts &&...ts)
 Apply an N-ary callable across \( N \) tuples zipped together.
template<int N, typename X>
auto triqs::tuple::make_tuple_repeat (X const &x)
 Build a tuple with \( N \) copies of a value.
template<typename F, typename T>
decltype(auto) triqs::tuple::map (F &&f, T &&t)
 Map a callable over the elements of a tuple.
template<typename... Ts, typename F>
auto triqs::tuple::map_on_zip (F &&f, Ts &&...ts)
 Map an N-ary callable across N tuples zipped together.
template<typename T1, typename T2>
std::ostream & std::operator<< (std::ostream &os, std::pair< T1, T2 > const &x)
 Write a std::pair to an output stream.
template<typename... T>
std::ostream & std::operator<< (std::ostream &os, std::tuple< T... > const &t)
 Write a std::tuple to an output stream.
template<typename T>
auto triqs::tuple::pop_front (T &&t)
 Remove the first element of a tuple.
template<typename T, typename X>
auto triqs::tuple::push_back (T &&t, X &&x)
 Append an element to the end of a tuple.
template<typename T, typename X>
auto triqs::tuple::push_front (T &&t, X &&x)
 Prepend an element to the front of a tuple.
template<int... Is, typename T, typename R>
auto triqs::tuple::replace (T &&t, R &&r)
 Return a copy of a tuple with the elements at the given positions replaced by a given value.