|
- #pragma once
-
- #include <cppargs/group/simple_group.h>
-
- namespace cppargs
- {
-
- template<typename T_arg>
- struct simple_verify_and_forward
- {
- template<typename T, typename T_enable = void>
- struct check
- {
- template<typename X>
- constexpr X&& operator()(X&& x) const
- { static_assert(sizeof(X) == -1, "invalid group or option type"); }
- };
-
- template<typename T>
- struct check<
- std::unique_ptr<T>,
- utl::mp::enable_if<utl::mp::is_base_of<simple_group, T>>>
- {
- template<typename X>
- constexpr X&& operator()(X&& x) const
- { return std::forward<X>(x); }
- };
-
- template<typename T>
- struct check<
- std::unique_ptr<T>,
- utl::mp::enable_if<utl::mp::is_base_of<simple_option, T>>>
- {
- template<typename X>
- constexpr X&& operator()(X&& x) const
- { return std::forward<X>(x); }
- };
-
- template<typename X>
- constexpr decltype(auto) operator()(X&& x) const
- { return check<T_arg> { } (std::forward<X>(x)); }
- };
-
- template<typename... T_args>
- simple_group::simple_group(
- const group_meta& p_meta,
- T_args&&... p_args)
- : group(p_meta, simple_verify_and_forward<T_args> { } (std::forward<T_args>(p_args))...)
- { }
-
- }
|