|
TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
|
Helpers for manipulating and serializing std::tuple and std::variant objects.
Classes | |
| struct | triqs::utility::overloaded< Fs > |
| Lambda-overload helper for std::visit. More... | |
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<typename Archive, typename... Ts> | |
| void | boost::serialization::load (Archive &ar, std::variant< Ts... > &v, const unsigned int version) |
| Deserialize a std::variant. | |
| 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, typename... Ts> | |
| std::ostream & | std::operator<< (std::ostream &os, std::variant< T, Ts... > const &v) |
| Write a std::variant to an output stream by visiting the held alternative and forwarding it to the stream. | |
| template<typename T, typename... Ts> | |
| std::ostream & | std::operator<< (std::ostream &os, std::vector< std::variant< T, Ts... > > const &vec) |
| Write a vector of std::variant as a comma-separated list of its elements. | |
| 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. | |
| template<typename Archive, typename... Ts> | |
| void | boost::serialization::save (Archive &ar, std::variant< Ts... > const &v, const unsigned int version) |
| Serialize a std::variant. | |
| template<typename Archive, typename... Ts> | |
| void | boost::serialization::serialize (Archive &ar, std::tuple< Ts... > &t, const unsigned int version) |
| Boost.Serialization entry point for std::tuple. | |
| string | std::to_string (string const &str) |
| Identity overload for std::string. | |
| template<typename T, typename... Ts> | |
| string | std::to_string (variant< T, Ts... > const &var) |
| Convert a variant into a string. | |
| using triqs::tuple::filter_out_t = std::decay_t<decltype(filter_out<Is...>(std::declval<T>()))> |
#include <triqs/utility/tuple_tools.hpp>
Result type of filter_out() for tuple type T dropping positions Is....
| T | Tuple type. |
| Is | Positions to drop. |
Definition at line 434 of file tuple_tools.hpp.
| using triqs::tuple::filter_t = std::tuple<std::tuple_element_t<Is, std::decay_t<T>>...> |
#include <triqs/utility/tuple_tools.hpp>
Tuple type made of the elements at the given positions of given tuple type T.
| T | Tuple type. |
| Is | Positions to keep. |
Definition at line 392 of file tuple_tools.hpp.
| decltype(auto) triqs::tuple::apply | ( | F && | f, |
| T && | t ) |
#include <triqs/utility/tuple_tools.hpp>
Call a function with the elements of a tuple as its arguments.
Equivalent to the C++17 std::apply.
| F | Callable type. |
| T | Tuple type. |
| f | Callable to invoke. |
| t | Tuple of arguments, i.e. t = (t0, t1, ...). |
Definition at line 159 of file tuple_tools.hpp.
| decltype(auto) triqs::tuple::apply_construct | ( | T && | t | ) |
#include <triqs/utility/tuple_tools.hpp>
Brace-construct an object from the elements of a tuple.
| C | Type to construct. |
| T | Tuple type. |
| t | Tuple of constructor arguments, i.e. t = (t0, t1, ...). |
Definition at line 174 of file tuple_tools.hpp.
| decltype(auto) triqs::tuple::apply_construct_parenthesis | ( | T && | t | ) |
#include <triqs/utility/tuple_tools.hpp>
Parenthesis-construct an object from the elements of a tuple.
| C | Type to construct. |
| T | Tuple type. |
| t | Tuple of constructor arguments, i.e. t = (t0, t1, ...). |
Definition at line 189 of file tuple_tools.hpp.
| auto triqs::tuple::called_on_tuple | ( | F && | f | ) |
#include <triqs/utility/tuple_tools.hpp>
Wrap a callable so that it can be invoked with a single tuple argument.
| F | Callable type. |
| f | Callable to wrap. |
Definition at line 206 of file tuple_tools.hpp.
| filter_t< T, Is... > triqs::tuple::filter | ( | T && | t | ) |
#include <triqs/utility/tuple_tools.hpp>
Keep only the elements of a tuple at the given positions.
| Is | Positions to keep. |
| T | Tuple type. |
| t | Source tuple. |
Definition at line 402 of file tuple_tools.hpp.
| filter_t< T, Is... > triqs::tuple::filter | ( | T && | t, |
| std::index_sequence< Is... > | ) |
#include <triqs/utility/tuple_tools.hpp>
Keep only the elements of a tuple at the given positions (as an index-sequence).
| Is | Positions to keep, supplied through the index-sequence argument. |
| T | Tuple type. |
| t | Source tuple. |
Definition at line 412 of file tuple_tools.hpp.
| decltype(auto) triqs::tuple::filter_out | ( | T && | t | ) |
#include <triqs/utility/tuple_tools.hpp>
Drop the elements of a tuple at the given positions.
| Is | Positions to drop. |
| T | Tuple type. |
| t | Source tuple. |
Definition at line 424 of file tuple_tools.hpp.
| decltype(auto) triqs::tuple::fold | ( | F && | f, |
| T && | t, | ||
| R && | r ) |
#include <triqs/utility/tuple_tools.hpp>
Left-fold a callable over the elements of a tuple.
Computes f(x_N, f(x_{N-1}, ... f(x_1, r))) for a tuple t = (x_1, ..., x_N).
| F | Callable type. |
| T | Tuple type. |
| R | Accumulator type. |
| f | Folding callable with signature f(x, r) -> r'. |
| t | Tuple to fold. |
| r | Initial accumulator value. |
Definition at line 324 of file tuple_tools.hpp.
| decltype(auto) triqs::tuple::fold | ( | F && | f, |
| T0 && | t1, | ||
| T1 && | t2, | ||
| R && | r ) |
#include <triqs/utility/tuple_tools.hpp>
Left-fold a callable over the elements of two equally-sized tuples.
Computes f(x_N, y_N, f(x_{N-1}, y_{N-1}, ... f(x_0, y_0, r))) for tuples t1 = (x_1, ..., x_N) and t2 = (y_1, ..., y_N).
| F | Callable type. |
| T0 | First tuple type. |
| T1 | Second tuple type. |
| R | Accumulator type. |
| f | Folding callable with signature f(x, y, r) -> r'. |
| t1 | First tuple to fold. |
| t2 | Second tuple to fold. |
| r | Initial accumulator value. |
Definition at line 354 of file tuple_tools.hpp.
| void triqs::tuple::for_each | ( | T && | t, |
| F && | f ) |
#include <triqs/utility/tuple_tools.hpp>
Apply a callable to every element of a tuple, in order.
| T | Tuple type. |
| F | Callable type. |
| t | Tuple to iterate over. |
| f | Callable invoked as f(x) for each element x of the tuple t. |
Definition at line 239 of file tuple_tools.hpp.
| void triqs::tuple::for_each_enumerate | ( | T && | t, |
| F && | f ) |
#include <triqs/utility/tuple_tools.hpp>
Apply a callable to every (index, element) pair of a tuple.
Mimics Python's for n, x in enumerate(t): f(n, x).
| T | Tuple type. |
| F | Callable type. |
| t | Tuple to iterate over. |
| f | Callable invoked as f(n, x) for each element x at index n of the tuple t. |
Definition at line 256 of file tuple_tools.hpp.
| void triqs::tuple::for_each_zip | ( | F && | f, |
| Ts &&... | ts ) |
#include <triqs/utility/tuple_tools.hpp>
Apply an N-ary callable across \( N \) tuples zipped together.
Mimics Python's for i1, ..., iN in zip(t1, ..., tN): f(i1, ..., iN). The tuples must have equal size.
| F | Callable type taking \( N \) arguments. |
| Ts | Tuple types. |
| f | Callable invoked on each zipped tuple of elements. |
| ts | The \( N \) tuples to zip and iterate over. |
Definition at line 270 of file tuple_tools.hpp.
| void boost::serialization::load | ( | Archive & | ar, |
| std::variant< Ts... > & | v, | ||
| const unsigned int | version ) |
#include <triqs/utility/variant_serialize.hpp>
Deserialize a std::variant.
| Archive | Archive type. |
| Ts | Alternative types of the variant. |
| ar | Boost archive. |
| v | Variant to deserialize into. |
| version | Unused version required by the Boost.Serialization protocol. |
Definition at line 84 of file variant_serialize.hpp.
| auto triqs::tuple::make_tuple_repeat | ( | X const & | x | ) |
#include <triqs/utility/tuple_tools.hpp>
Build a tuple with \( N \) copies of a value.
| N | Number of elements (non-negative). |
| X | Element type. |
| x | Value to repeat. |
Definition at line 141 of file tuple_tools.hpp.
| decltype(auto) triqs::tuple::map | ( | F && | f, |
| T && | t ) |
#include <triqs/utility/tuple_tools.hpp>
Map a callable over the elements of a tuple.
| F | Callable type. |
| T | Tuple type. |
| f | Callable applied to each element. |
| t | Tuple to map over. |
Definition at line 288 of file tuple_tools.hpp.
| auto triqs::tuple::map_on_zip | ( | F && | f, |
| Ts &&... | ts ) |
#include <triqs/utility/tuple_tools.hpp>
Map an N-ary callable across N tuples zipped together.
| Ts | Tuple types. |
| F | Callable type. |
| f | Callable applied to each zipped tuple of elements. |
| ts | The \( N \) tuples to zip and map over. |
Definition at line 299 of file tuple_tools.hpp.
| std::ostream & std::operator<< | ( | std::ostream & | os, |
| std::pair< T1, T2 > const & | x ) |
#include <triqs/utility/tuple_tools.hpp>
Write a std::pair to an output stream.
| T1 | Type of the first element. |
| T2 | Type of the second element. |
| os | Output stream. |
| x | Pair to write. |
Definition at line 504 of file tuple_tools.hpp.
| std::ostream & std::operator<< | ( | std::ostream & | os, |
| std::tuple< T... > const & | t ) |
#include <triqs/utility/tuple_tools.hpp>
Write a std::tuple to an output stream.
| T | Types of the tuple elements. |
| os | Output stream. |
| t | Tuple to write. |
Definition at line 486 of file tuple_tools.hpp.
| std::ostream & std::operator<< | ( | std::ostream & | os, |
| std::variant< T, Ts... > const & | v ) |
#include <triqs/utility/variant_extensions.hpp>
Write a std::variant to an output stream by visiting the held alternative and forwarding it to the stream.
| T | First alternative type. |
| Ts | Remaining alternative types. |
| os | Output stream. |
| v | Variant to write. |
Definition at line 66 of file variant_extensions.hpp.
| std::ostream & std::operator<< | ( | std::ostream & | os, |
| std::vector< std::variant< T, Ts... > > const & | vec ) |
#include <triqs/utility/variant_extensions.hpp>
Write a vector of std::variant as a comma-separated list of its elements.
| T | First alternative type. |
| Ts | Remaining alternative types. |
| os | Output stream. |
| vec | Vector of variants to write. |
Definition at line 80 of file variant_extensions.hpp.
| auto triqs::tuple::pop_front | ( | T && | t | ) |
#include <triqs/utility/tuple_tools.hpp>
Remove the first element of a tuple.
| T | Tuple type. |
| t | Source tuple. |
Definition at line 465 of file tuple_tools.hpp.
| auto triqs::tuple::push_back | ( | T && | t, |
| X && | x ) |
#include <triqs/utility/tuple_tools.hpp>
Append an element to the end of a tuple.
| T | Tuple type. |
| X | Element type. |
| t | Source tuple. |
| x | Element to append. |
Definition at line 445 of file tuple_tools.hpp.
| auto triqs::tuple::push_front | ( | T && | t, |
| X && | x ) |
#include <triqs/utility/tuple_tools.hpp>
Prepend an element to the front of a tuple.
| T | Tuple type. |
| X | Element type. |
| t | Source tuple. |
| x | Element to prepend. |
Definition at line 456 of file tuple_tools.hpp.
| auto triqs::tuple::replace | ( | T && | t, |
| R && | r ) |
#include <triqs/utility/tuple_tools.hpp>
Return a copy of a tuple with the elements at the given positions replaced by a given value.
| Is | Positions to replace. |
| T | Tuple type. |
| R | Replacement type. |
| t | Source tuple. |
| r | Replacement value. |
Definition at line 382 of file tuple_tools.hpp.
| void boost::serialization::save | ( | Archive & | ar, |
| std::variant< Ts... > const & | v, | ||
| const unsigned int | version ) |
#include <triqs/utility/variant_serialize.hpp>
Serialize a std::variant.
| Archive | Archive type. |
| Ts | Alternative types of the variant. |
| ar | Boost archive. |
| v | Variant to serialize. |
| version | Unused version required by the Boost.Serialization protocol. |
Definition at line 68 of file variant_serialize.hpp.
| void boost::serialization::serialize | ( | Archive & | ar, |
| std::tuple< Ts... > & | t, | ||
| const unsigned int | version ) |
#include <triqs/utility/tuple_serialize.hpp>
Boost.Serialization entry point for std::tuple.
| Archive | Archive type. |
| Ts | Tuple element types. |
| ar | Boost archive. |
| t | Tuple to serialize. |
| version | Unused version required by the Boost.Serialization protocol. |
Definition at line 54 of file tuple_serialize.hpp.
|
inline |
#include <triqs/utility/variant_extensions.hpp>
Convert a variant into a string.
It uses a stringstream and the std::operator<<(std::ostream&, std::variant<T, Ts...> const&) overload.
| T | First alternative type. |
| Ts | Remaining alternative types. |
| var | Variant to convert. |
Definition at line 102 of file variant_extensions.hpp.