From 3883c598e5560a9b1a2fb4cf762c698b22d22e18 Mon Sep 17 00:00:00 2001 From: sowle Date: Sat, 25 Apr 2020 17:22:34 +0300 Subject: [PATCH] handle_2_alternative_types_in_variant_container --- .../currency_format_utils_abstract.h | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/currency_core/currency_format_utils_abstract.h b/src/currency_core/currency_format_utils_abstract.h index 212e133e..d6a48212 100644 --- a/src/currency_core/currency_format_utils_abstract.h +++ b/src/currency_core/currency_format_utils_abstract.h @@ -107,6 +107,28 @@ namespace currency return false; } //--------------------------------------------------------------- + template + bool handle_2_alternative_types_in_variant_container(const container_t& container, callback_t& cb) + { + bool found = false; + for (auto& item : container) + { + if (item.type() == typeid(A)) + { + found = true; + if (!cb(boost::get(item))) + break; + } + else if (item.type() == typeid(B)) + { + found = true; + if (!cb(boost::get(item))) + break; + } + } + return found; + } + //--------------------------------------------------------------- template bool check_allowed_types_in_variant_container(const variant_container_t& container, const std::unordered_set& allowed_types, bool elements_must_be_unique = true) {