1
0
Fork 0
forked from lthn/blockchain

handle_2_alternative_types_in_variant_container

This commit is contained in:
sowle 2020-04-25 17:22:34 +03:00
parent 898d6c7f2d
commit 3883c598e5
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC

View file

@ -107,6 +107,28 @@ namespace currency
return false;
}
//---------------------------------------------------------------
template <typename A, typename B, typename container_t, typename callback_t>
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<A>(item)))
break;
}
else if (item.type() == typeid(B))
{
found = true;
if (!cb(boost::get<A>(item)))
break;
}
}
return found;
}
//---------------------------------------------------------------
template<typename variant_container_t>
bool check_allowed_types_in_variant_container(const variant_container_t& container, const std::unordered_set<std::type_index>& allowed_types, bool elements_must_be_unique = true)
{