-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes for BSIP40 custom authorities #79
Conversation
include/fc/static_variant.hpp
Outdated
@@ -326,6 +326,16 @@ class static_variant { | |||
return impl::storage_ops<0, Types...>::apply(_tag, storage, v); | |||
} | |||
|
|||
template<tag_type w, typename visitor> | |||
static typename visitor::result_type visit(visitor& v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR comment indicates that this intends to provide the
ability to get data type with a given index (which) without constructing an object
If it's only about this then a construct like position<> might be more efficient. But if you need the visitor it's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The visitor is used here. (I assume) it just works. Perhaps there are better implementation though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
include/fc/static_variant.hpp
Outdated
static typename visitor::result_type visit( tag_type tag, visitor& v, void* data ) | ||
{ | ||
static std::vector<std::function<typename visitor::result_type(visitor&,void*)>> wrappers = init_wrappers<visitor,void*,Types...>(); | ||
FC_ASSERT( tag < count(), "Unsupported type ${tag}!", ("tag",tag) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert tag >= 0
as well?
BTW please wrap long lines (perhaps can use auto
here)? (BTW just found that Github in Firefox in Ubuntu desktop 18.04 only shows 123 characters a line, while in Chrome in Windows 7 it shows 130 characters)
Compiled and ran tests on Ubuntu 18.04 / Boost 1.67 / OpenSSL 1.10. All without errors ( Unrelated note: The app Not approving PR to give @pmconrad a chance to wrap lines. But all looks good to me. |
include/fc/static_variant.hpp
Outdated
template<typename Visitor,typename Data, typename T, typename ... Types> | ||
std::vector<std::function<typename Visitor::result_type(Visitor&,Data)>> init_const_wrappers() | ||
{ | ||
std::vector<std::function<typename Visitor::result_type(Visitor&,Data)>> result = init_const_wrappers<Visitor,Data,Types...>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is still too long for me..
include/fc/static_variant.hpp
Outdated
template<typename Visitor,typename Data, typename T, typename ... Types> | ||
std::vector<std::function<typename Visitor::result_type(Visitor&,Data)>> init_wrappers() | ||
{ | ||
std::vector<std::function<typename Visitor::result_type(Visitor&,Data)>> result = init_wrappers<Visitor,Data,Types...>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is OK in Chrome but too long in Firefox
@jmjatlanta since both abit and me have contributed code, could you please re-review and approve? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good. Thank you both!
0# fc::print_stacktrace(std::ostream&) in tests/all_tests Compiled on Ubutntu 18.04 / Boost 1.65.1 |
This PR contains changes need in FC for implementing custom active authorities (BSIP40 / bitshares/bitshares-core#1285):
variant
: a function to convertbool
tovariant
;static_variant
: ability to get data type with a given index (which
) without constructing an object;reflector
: ability to visit local member of reflected data structure by index (was only able to visit by name).Ready for merge.