NamedArg
NamedArg
Section titled “NamedArg”#include <sbio/util/parameters.hh>template<FixedName Key>struct NamedArgDefined in src/lib/sbio/util/parameters.hh:251
A mechanism to attach a name/keyword to an argument.
Classes and structs with constructors accepting NamedArg instances, and in general multiple using variadic templates, can have various associated utilities to make it more ergonomic to use them. This provides a semblance of keyword arguments in standard C++.
Currently, the main recommendation is to provide an associated literal to the class argument, allow it to be used in any position in the constructor and with the attached literal functioning as a keyword. E.g.: &
namespace literals { constexpr auto operator ""_alg(const char* str, hd_std::size_t) { return NamedArg<"alg"> { str } }} // namespace literals
// Now, constructors accepting these NamedArg (like DataRequest) have kwargsDataRequest("value_of_alg"_alg);Public Attributes
Section titled “Public Attributes”| Return | Name | Description |
|---|---|---|
const char * |
value |
const char * value { nullptr }Defined in src/lib/sbio/util/parameters.hh:254
Public Static Attributes
Section titled “Public Static Attributes”| Return | Name | Description |
|---|---|---|
constexpr auto |
key_name static constexpr |
key_name
Section titled “key_name”static constexpr
constexpr auto key_name { Key }Defined in src/lib/sbio/util/parameters.hh:252