7 #ifndef AR_ENABLE_CPP20_STRINGS
9 # include "arg_router/basic_types.hpp"
10 # include "arg_router/utility/tuple_iterator.hpp"
66 template <
typename Fn,
typename... SupportedISOLanguageCodes>
69 constexpr
static auto num_supported_codes =
sizeof...(SupportedISOLanguageCodes);
70 static_assert(num_supported_codes > 1,
"Must be more than one language provided");
72 using supported_codes = std::tuple<SupportedISOLanguageCodes...>;
73 static_assert(num_supported_codes == std::tuple_size_v<boost::mp11::mp_unique<supported_codes>>,
74 "Supported ISO language codes must be unique");
76 template <std::size_t... I>
77 constexpr
static auto indicies_to_variant(std::index_sequence<I...>) -> std::variant<
80 using root_variant_t =
81 decltype(indicies_to_variant(std::make_index_sequence<num_supported_codes>{}));
82 using supported_iso_languages = std::tuple<SupportedISOLanguageCodes...>;
91 [[deprecated(
"Superceded by multi_lang::root_t, will be removed in v2")]]
94 utility::tuple_type_iterator<boost::mp11::mp_iota_c<num_supported_codes>>([&](
auto I) {
96 (iso_language != std::tuple_element_t<I, supported_iso_languages>::get())) {
100 root_.emplace(root_variant_t{f(I)});
114 void parse(
int argc,
char** argv)
const
116 std::visit([&](
const auto&
root) {
root.parse(argc, argv); }, *root_);
123 void help(std::ostream& stream)
const
125 std::visit([&](
const auto&
root) {
root.help(stream); }, *root_);
132 [[nodiscard]]
string help()
const
134 return std::visit([](
const auto&
root) {
root.help(); }, *root_);
139 std::optional<root_variant_t> root_;
151 template <
typename... SupportedISOLanguageCodes,
typename Fn>
152 [[nodiscard, deprecated(
"Superceded by multi_lang::root, will be removed in v2")]]
155 return root_wrapper_t<Fn, SupportedISOLanguageCodes...>{iso_language, std::forward<Fn>(f)};
root_wrapper_t(std::string_view iso_language, Fn &&f)
void parse(int argc, char **argv) const
void help(std::ostream &stream) const
auto root(std::string_view language_id, const RootFactory &f)
auto root_wrapper(std::string_view iso_language, Fn &&f)
std::integral_constant< decltype(Value), Value > integral_constant