diff --git a/libraries/fc b/libraries/fc index 5768c6d884..e1ed222667 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 5768c6d884f85dce20ec481c1dc0213df9372b14 +Subproject commit e1ed222667d3430fcdb53db20d60ddbeadaee395 diff --git a/libraries/protocol/custom_authorities/restriction_predicate.hxx b/libraries/protocol/custom_authorities/restriction_predicate.hxx index 9d2757b787..5eac38994b 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"); diff --git a/libraries/protocol/custom_authorities/sliced_lists.hxx b/libraries/protocol/custom_authorities/sliced_lists.hxx index 005759c2bf..588a92d5cc 100644 --- a/libraries/protocol/custom_authorities/sliced_lists.hxx +++ b/libraries/protocol/custom_authorities/sliced_lists.hxx @@ -29,21 +29,25 @@ namespace graphene { namespace protocol { namespace typelist = fc::typelist; +// Shorthand to convert a typelist into a static_variant of that typelist +template +using to_sv = typelist::apply; + // To make the build gentler on RAM, break the operation list into several pieces to build over several files -using operation_list_1 = static_variant>; -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 - ::add // 43 - ::add // 45 - ::add_list> - ::add // 52 - ::finalize>; -using operation_list_9 = 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 + ::add // 43 + ::add // 45 + ::add_list> + ::add // 52 + ::finalize>; +using operation_list_9 = to_sv>; using virtual_operations_list = static_variant > { 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 e07aa10899..2342159837 100644 --- a/tests/tests/custom_authority_tests.cpp +++ b/tests/tests/custom_authority_tests.cpp @@ -52,6 +52,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) { @@ -59,7 +60,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); } } }