Skip to content

NamedArg

#include <sbio/util/parameters.hh>
template<FixedName Key>
struct NamedArg

Defined 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 kwargs
DataRequest("value_of_alg"_alg);
Return Name Description
const char * value

const char * value { nullptr }

Defined in src/lib/sbio/util/parameters.hh:254

Return Name Description
constexpr auto key_name static constexpr

static constexpr

constexpr auto key_name { Key }

Defined in src/lib/sbio/util/parameters.hh:252