|
std::ostream & | operator<< (std::ostream &stream, const dynamic_string_view &dsv) |
|
template<typename T > |
dynamic_string_view | operator+ (dynamic_string_view a, T &&b) |
|
template<typename Visitor , typename Root > |
constexpr void | tree_recursor (Visitor visitor, const Root &root) |
|
template<typename Visitor , typename SkipFn , typename Root > |
constexpr void | tree_type_recursor () |
|
template<typename Visitor , typename Root > |
constexpr void | tree_type_recursor () |
|
template<typename F , typename Tuple > |
constexpr std::enable_if_t< traits::is_tuple_like_v< std::decay_t< Tuple > > > | tuple_iterator (F &&f, Tuple &&tuple) |
|
template<typename F , typename... T> |
constexpr void | tuple_iterator (F &&f, T &&... pack) |
|
template<typename Tuple , typename F > |
constexpr std::enable_if_t< traits::is_tuple_like_v< std::decay_t< Tuple > > > | tuple_type_iterator (F &&f) |
|
template<typename T > |
std::size_t | type_hash () noexcept |
|
Namespace for utility types and functions.
template<typename Visitor , typename Root >
constexpr void arg_router::utility::tree_recursor |
( |
Visitor |
visitor, |
|
|
const Root & |
root |
|
) |
| |
|
constexpr |
Depth-first search of the node tree, calling visitor on every tree_node.
Visitor must be a Callable with the same method signatue as below:
template <typename Current, typename... Parents>
void operator()(const Current& current, const Parents&... parents)
{
...
}
Where current
is the current node from the tree, and parents
is a pack of ancestors in increasing generation from current
. The last in the pack is always root.
- Template Parameters
-
Visitor | Visitor type |
Root | tree_node derived type to start from |
- Parameters
-
visitor | Callable called on each tree_node visited |
root | Tree node to start from (must be a tree_node derived type!) |
Definition at line 102 of file tree_recursor.hpp.
template<typename Visitor , typename SkipFn , typename Root >
constexpr void arg_router::utility::tree_type_recursor |
( |
| ) |
|
|
constexpr |
Depth-first recurse through the parse tree, calling Visitor on every tree_node and its policies.
Visitor must be object with the same method signatue as below:
struct my_fn {
template <typename Current, typename... Parents>
constexpr static void fn()
{
...
}
};
Where Current
is the current type from the tree, and Parents
is a pack of ancestors in increasing generation from Current
. The last in the pack is always the root.
SkipFn must be object with the same method signatue as below:
struct my_skip_fn {
template <typename Current, typename... Parents>
constexpr static bool fn()
{
...
return condition_met;
}
};
If the return value is true, then the Current
node or policy and any subtree below it are skipped i.e. fn
is not called.
- Note
- Unlike tree_recursor(Visitor visitor, const Root& root), this will recurse into tree_node policies.
- Template Parameters
-
Visitor | Visitor type |
SkipFn | Skip function type |
Root | Start object type in the parse tree |
Definition at line 145 of file tree_recursor.hpp.
template<typename T >
std::size_t arg_router::utility::type_hash |
( |
| ) |
|
|
noexcept |
Hash generation for a type.
This is intended to replace typeid(T).hash_code()
, as the use of typeid causes huge amounts of class name data to be put into the binary's static data storage - which isn't used!
- Note
- Aliases are resolved by the compiler in a pre-processing stage before this, so
type_hash<std::uint64_t>() == type_hash<unsigned long>()
(on a 64bit system)
Anyone reading the implementation will see that this is not a hash function, it just takes the address of the instantiated function. Originally this used the hash of the PRETTY_FUNCTION
output and therefore could be used at compile-time. Unfortunately that was ruined when C++20 compile-time string support was added, due to a bug in gcc (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108269) which produced incorrect output when std::array
was used inside an NTTP.
- Parameters
-
T | Type to generate a hash code for |
- Returns
- Hash code of T
Definition at line 29 of file type_hash.hpp.