|
|
@@ -162,6 +162,23 @@ template <typename Impl> bool Arguments<Impl>::Option::primed() const {
|
|
|
|
|
|
}
|
|
|
|
|
|
+namespace program {
|
|
|
+template <typename Impl>
|
|
|
+template <typename T>
|
|
|
+auto Arguments<Impl>::Rest::operator=(T && value) {
|
|
|
+ return WithDefault<Rest, T>{*this, std::forward<T>(value)};
|
|
|
+}
|
|
|
+
|
|
|
+template <typename Impl>
|
|
|
+Arguments<Impl>::Rest::operator std::vector<std::string>() const {
|
|
|
+ return (*this) ? self->args() : std::vector<std::string>();
|
|
|
+}
|
|
|
+
|
|
|
+template <typename Impl> Arguments<Impl>::Rest::operator bool() const {
|
|
|
+ return self->arguments.size() > self->argument_names.size();
|
|
|
+}
|
|
|
+}
|
|
|
+
|
|
|
namespace program {
|
|
|
|
|
|
template <typename Impl>
|
|
|
@@ -170,7 +187,7 @@ template <typename T>
|
|
|
Arguments<Impl>::WithDefault<B, V>::operator T() const {
|
|
|
if (impl) { return impl; }
|
|
|
if constexpr (std::is_invocable_r<T, V>{}) {
|
|
|
- return T(default_value());
|
|
|
+ return T{default_value()};
|
|
|
} else {
|
|
|
return T{default_value};
|
|
|
}
|
|
|
@@ -300,16 +317,14 @@ auto Arguments<Impl>::argument(size_t index, LongArg name,
|
|
|
}
|
|
|
|
|
|
template <typename Impl>
|
|
|
-std::vector<std::string>
|
|
|
-Arguments<Impl>::rest(LongArg name, std::string const & description) {
|
|
|
+auto Arguments<Impl>::rest(LongArg name, std::string const & description) {
|
|
|
if (has_actions()) { throw ArgumentMixingError(); }
|
|
|
if (!rest_name.empty() && rest_name != name.str) {
|
|
|
throw ArgumentStructureError("duplicate rest() parameter", name);
|
|
|
}
|
|
|
rest_name = name;
|
|
|
argument_descriptions.emplace(name, description);
|
|
|
- size_t const i = std::min(arguments.size(), argument_names.size());
|
|
|
- return {arguments.begin() + i, arguments.end()};
|
|
|
+ return Rest{this};
|
|
|
}
|
|
|
|
|
|
template <typename Impl>
|