A helper class for simulation named arguments in c++.
- Template Parameters
-
Args | The types of the named arguments. |
This class is used to take a list of named arguments and store them in a form easily accessible by the user. This facility includes the helper functions util::get_named_argument and util::get_named_argument_or which can be used to access the named arguments.
Named arguments are declared using CRTP with the util::NamedArgument class. The current implementation allows all named arguments to be optional, but this may change in the future.
The folllowing example shows how to use this class and related methods:
struct Foo : di::NamedArgument<Foo, i32> {};
struct Bar : di::NamedArgument<Bar, i32> {};
template<di::concepts::Integral T>
struct Baz : di::NamedArgument<di::InPlaceTemplate<Baz>, T> {};
template<typename T>
Baz(T&&) -> Baz<T>;
template<typename... Args>
requires(di::ValidNamedArguments<di::meta::List<Foo, Bar, di::InPlaceTemplate<Baz>>, Args...>)
constexpr static auto f(Args&&... args) ->
i32 {
auto named = di::NamedArguments(di::forward<Args>(args)...);
return foo_value + bar_value + baz_value;
}
constexpr static void named_arguments() {
}
- See also
- NamedArgument
-
get_named_argument
-
get_named_argument_or