template<class List>
TaggedTuple class
Tagged tuple, allowing tag-based access.
Template parameters | |
---|---|
List | Type list as brigand::list |
Contents
"Tag" here is any type, but mostly an empty struct with a good name for the data member
Public types
- using PairList = List
- List of key-value pairs.
- using Keys = typename Pair::second_type
- List of keys.
- using i_am_tagged_tuple = void
- Typedef defining self for identifying self.
-
template<typename Tag>using TupleElement = std::tuple_element_t<brigand::index_of<Keys, Tag>::value, Tuple>
- Acces type in tuple behind tag.
-
template<typename Tag>using is_tagged_tuple = is_
tagged_ tuple_ t<std::decay_t<TupleElement<Tag>>>
Public static functions
- static auto size() -> std::size_t constexpr
- Return number of tuple entries.
Constructors, destructors, conversion operators
- TaggedTuple() defaulted explicit
- Default constructor.
- TaggedTuple(Tuple&& tuple) explicit
- Initializer constructor.
Public functions
- auto tuple() const -> const Tuple&
- Const-ref access to member tuple.
-
template<typename Tag, typename... Tags>auto get() const -> const auto& noexcept
- Const-reference data member accessor of field of tagged tuple at depth.
-
template<typename Tag, typename... Tags>auto get() -> auto& noexcept
- Reference data member accessor of field of tagged tuple at depth.
-
template<typename Tag, typename... Tags>void store(const std::string& value) noexcept
-
template<typename Tag, typename... Tags>void store_back(const std::string& value) noexcept
-
template<typename Tag, typename... Tags>void store_back_bool(const std::string& value) noexcept
-
template<typename Tag, typename... Tags>void store_back_back(const std::string& value) noexcept
- Convert and push back value, converting from string, to back of a nested vector.
-
template<typename Tag, typename... Tags>void store_back_back_back(const std::string& value) noexcept
- Convert and push back value, converting from string, to back of a doubly nested vector.
-
template<typename Tag, typename... Tags, typename Key, typename Value>void insert(const Key& key, const Value& value)
- Insert key-value pair, converting value from string, to map.
-
template<typename FieldTag, typename FieldType, typename Tag, typename... Tags, typename Key>void insert_field(const Key& key, const FieldType& value)
- Insert key-value pair to map of nested TaggedTuple.
-
template<typename FieldTag, typename FieldType, typename Tag, typename... Tags, typename Key>void insert_field(const Key& key, const std::string& value)
- Insert key-value pair, converting value from string, to map of nested TaggedTuple.
-
template<typename L>auto operator==(const TaggedTuple<L>& t) const -> bool
-
template<typename L>auto operator<(const TaggedTuple<L>& t) const -> bool
Charm++ pack/unpack serializer member functions
Pack/Unpack
- void pup(PUP::er& p)
- Pack/Unpack serialize member function.
-
template<typename type>auto convert(const std::string& str) -> type
- auto convert_bool(const std::string& str) -> int
- void operator|(PUP::er& p, TaggedTuple<List>& t)
- Pack/Unpack serialize operator|.
Typedef documentation
template<class List>
template<typename Tag>
using tk:: TaggedTuple<List>:: is_tagged_tuple = is_ tagged_ tuple_ t<std::decay_t<TupleElement<Tag>>>
Query if the type behind Tag is a TaggedTuple Usage: if constexpr( is_tagged_tuple<Tag>::value ) { ... }
Function documentation
template<class List>
template<typename Tag, typename... Tags>
void tk:: TaggedTuple<List>:: store(const std::string& value) noexcept
Parameters | |
---|---|
value in | Value to convert and store |
Convert and store value converting from string at depth
template<class List>
template<typename Tag, typename... Tags>
void tk:: TaggedTuple<List>:: store_back(const std::string& value) noexcept
Parameters | |
---|---|
value in | Value to convert and store |
Convert and push back value, converting from string, to vector
template<class List>
template<typename Tag, typename... Tags>
void tk:: TaggedTuple<List>:: store_back_bool(const std::string& value) noexcept
Parameters | |
---|---|
value in | Value to convert and store |
Convert bool and push back, converting from string, to vector of ints
template<class List>
template<typename Tag, typename... Tags>
void tk:: TaggedTuple<List>:: store_back_back(const std::string& value) noexcept
Convert and push back value, converting from string, to back of a nested vector.
Parameters | |
---|---|
value in | Value to convert and store |
template<class List>
template<typename Tag, typename... Tags>
void tk:: TaggedTuple<List>:: store_back_back_back(const std::string& value) noexcept
Convert and push back value, converting from string, to back of a doubly nested vector.
Parameters | |
---|---|
value in | Value to convert and store |
template<class List>
template<typename L>
bool tk:: TaggedTuple<List>:: operator==(const TaggedTuple<L>& t) const
Template parameters | |
---|---|
L | Type list as brigand::list for other TaggedTuple |
Returns | True if the lhs and rhs equal |
Operator == between two TaggedTuple objects
template<class List>
template<typename L>
bool tk:: TaggedTuple<List>:: operator<(const TaggedTuple<L>& t) const
Template parameters | |
---|---|
L | Type list as brigand::list for other TaggedTuple |
Returns | True if lhs < rhs |
Operator < between two TaggedTuple objects
template<class List>
void tk:: TaggedTuple<List>:: pup(PUP::er& p)
Pack/Unpack serialize member function.
Parameters | |
---|---|
p in/out | Charm++'s PUP::er serializer object reference |
template<class List>
template<typename type>
type tk:: TaggedTuple<List>:: convert(const std::string& str)
Parameters | |
---|---|
str in | String to convert |
Returns | A value of type given by the template argument |
Convert/parse string to and return as type given by template argument
template<class List>
int tk:: TaggedTuple<List>:: convert_bool(const std::string& str)
Parameters | |
---|---|
str in | String to convert |
Returns | Bool parsed from str returned as an int |
Convert/parse string to bool and return as int Parsing a bool from a string, e.g., "true" or "false" is special compared to the above convert template, because the type into which we parse to (from stringstream) must be bool, but its value must be returned as an int. Input data stored this way ensures that the data is stored as an int and not a bool, which could be problematic if stored in a std::vector. Using this function via store_back_bool is a better way to achieve type-safety of the user input and ensures data does not get corrupted during Charm++ serialization as distributed to multiple PEs.
template<class List>
void tk:: TaggedTuple<List>:: operator|(PUP::er& p,
TaggedTuple<List>& t)
Pack/Unpack serialize operator|.
Parameters | |
---|---|
p in/out | Charm++'s PUP::er serializer object reference |
t in/out | TaggedTuple object reference |