Class ArgVector
Defined in File ArgVector.hpp
Class Documentation
-
class ArgVector
Represents a set of 0 or more values associated with a given command-line option.
This class allows the internal data to be interpreted as a discrete set of values (std::array) of a given type or as a single value, hopefully making it more intuitive for users. For example…
If an ArgVector v is expected to hold one value of type
double, that value can be extracted withauto r = v.as<double>();. This meansrwill be adoublevalue assigned with the contents of the first element ofv.If an ArgVector v is expected to hold two values of type
int, on the other hand, the values can be extracted as astd::array<int, 2>usingas<int, 2>(). Usingstd::arrayallows structured bindings for the user:auto [a, b] = v.as<int, 2>();Public Functions
-
ArgVector() = default
Default is empty (no values)
-
template<typename T, std::size_t N>
inline std::array<T, N> as() const Interpret as
Nvalues of typeT
-
template<std::size_t N>
inline decltype(auto) as() const Interpret as
Nvalues of typestd::string
-
template<typename T>
inline decltype(auto) as() const Interpret as single value of type
T
-
inline const std::string &operator()() const
Interpret as single
std::stringvalue.
-
inline bool empty() const
Check for existence of values.
-
ArgVector() = default