diff --git a/libraries/fc b/libraries/fc index bae416a446..e1ed222667 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit bae416a4462a9d59b0f3078a407218bbe12f0f96 +Subproject commit e1ed222667d3430fcdb53db20d60ddbeadaee395 diff --git a/libraries/protocol/custom_authorities/restriction_predicate.hxx b/libraries/protocol/custom_authorities/restriction_predicate.hxx index 5fa7f1ff14..d38330e155 100644 --- a/libraries/protocol/custom_authorities/restriction_predicate.hxx +++ b/libraries/protocol/custom_authorities/restriction_predicate.hxx @@ -75,6 +75,10 @@ template const auto& to_num(const fc::safe& i) { return i.value; } inline auto to_num(const fc::time_point_sec& t) { return t.sec_since_epoch(); } +// Shorthand to convert a typelist into a static_variant of that typelist +template +using to_sv = typelist::apply; + namespace safenum = boost::safe_numerics::safe_compare; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -127,7 +131,7 @@ using comparable_types_list = typelist::list; // Valid for list functions (in, not_in, has_all, has_none) -struct make_flat_set { template struct transform { using type = flat_set; }; }; +template struct make_flat_set { using type = flat_set; }; using list_types_list = typelist::transform, comparable_types_list>, make_flat_set>; @@ -256,9 +260,15 @@ template struct predicate_in, flat_set, std::enable_if_t>> { // Check for optional value constexpr static bool valid = true; + template::value, bool> = true> bool operator()(const fc::optional& f, const flat_set& c) const { if (!f.valid()) return predicate_result::Rejection(predicate_result::null_optional); - return c.count(*f) != 0; + return c.count(*f) != 0; + } + template::value, bool> = true> + bool operator()(const fc::optional& f, const flat_set& c) const { + if (!f.valid()) return predicate_result::Rejection(predicate_result::null_optional); + return c.count(Element(f->value)) != 0; } }; template @@ -470,32 +480,25 @@ object_restriction_predicate create_predicate_function(restriction_functi try { switch(func) { case restriction::func_eq: - return make_predicate(static_variant::import_from(std::move(arg))); + return make_predicate(to_sv::import_from(std::move(arg))); case restriction::func_ne: - return make_predicate(static_variant::import_from(std::move(arg))); + return make_predicate(to_sv::import_from(std::move(arg))); case restriction::func_lt: - return make_predicate(static_variant - ::import_from(std::move(arg))); + return make_predicate(to_sv::import_from(std::move(arg))); case restriction::func_le: - return make_predicate(static_variant - ::import_from(std::move(arg))); + return make_predicate(to_sv::import_from(std::move(arg))); case restriction::func_gt: - return make_predicate(static_variant - ::import_from(std::move(arg))); + return make_predicate(to_sv::import_from(std::move(arg))); case restriction::func_ge: - return make_predicate(static_variant - ::import_from(std::move(arg))); + return make_predicate(to_sv::import_from(std::move(arg))); case restriction::func_in: - return make_predicate(static_variant::import_from(std::move(arg))); + return make_predicate(to_sv::import_from(std::move(arg))); case restriction::func_not_in: - return make_predicate(static_variant - ::import_from(std::move(arg))); + return make_predicate(to_sv::import_from(std::move(arg))); case restriction::func_has_all: - return make_predicate(static_variant - ::import_from(std::move(arg))); + return make_predicate(to_sv::import_from(std::move(arg))); case restriction::func_has_none: - return make_predicate(static_variant - ::import_from(std::move(arg))); + return make_predicate(to_sv::import_from(std::move(arg))); case restriction::func_attr: FC_ASSERT(arg.which() == restriction_argument::tag>::value, "Argument type for attribute assertion must be restriction list"); @@ -590,14 +593,14 @@ object_restriction_predicate restrictions_to_predicate(vector>; -using operation_list_2 = static_variant>; -using operation_list_3 = static_variant>; -using operation_list_4 = static_variant>; -using operation_list_5 = static_variant>; -using operation_list_6 = static_variant>; -using operation_list_7 = static_variant>; -using operation_list_8 = static_variant>; +using operation_list_1 = to_sv>; +using operation_list_2 = to_sv>; +using operation_list_3 = to_sv>; +using operation_list_4 = to_sv>; +using operation_list_5 = to_sv>; +using operation_list_6 = to_sv>; +using operation_list_7 = to_sv>; +using operation_list_8 = to_sv>; object_restriction_predicate get_restriction_predicate_list_1(size_t idx, vector rs); object_restriction_predicate get_restriction_predicate_list_2(size_t idx, vector rs); diff --git a/libraries/protocol/include/graphene/protocol/object_id.hpp b/libraries/protocol/include/graphene/protocol/object_id.hpp index 7f627e4b19..d26aa981e2 100644 --- a/libraries/protocol/include/graphene/protocol/object_id.hpp +++ b/libraries/protocol/include/graphene/protocol/object_id.hpp @@ -169,7 +169,7 @@ struct reflector > { typedef graphene::db::object_id type; typedef std::true_type is_defined; - using native_members = typelist::list>; + using native_members = typelist::list>; using inherited_members = typelist::list<>; using members = native_members; using base_classes = typelist::list<>; diff --git a/tests/tests/custom_authority_tests.cpp b/tests/tests/custom_authority_tests.cpp index d08551c472..4a403f858b 100644 --- a/tests/tests/custom_authority_tests.cpp +++ b/tests/tests/custom_authority_tests.cpp @@ -35,6 +35,7 @@ using namespace graphene::chain; using namespace graphene::chain::test; +namespace TL = fc::typelist; namespace graphene { namespace protocol { bool operator==(const restriction& a, const restriction& b) { @@ -42,7 +43,7 @@ bool operator==(const restriction& a, const restriction& b) { return false; if (a.argument.is_type()) return b.argument.is_type(); - using Value_Argument = static_variant>; + using Value_Argument = TL::apply, static_variant>; return Value_Argument::import_from(a.argument) == Value_Argument::import_from(b.argument); } } }