
Hi,
1. I wanted to get hash map stats, but they are not printed in debug policy, even when env variable is set
There is a small bug here. If you try with the "review" branch, or use <https://raw.githubusercontent.com/jll63/Boost.OpenMethod/refs/heads/review/flat/boost/openmethod.hpp> in compiler explorer, you will get the hash stats. See https://godbolt.org/z/bneKT6s7v Now an important thing: if you build with NDEBUG defined, the default policy is debug. Otherwise it is release. I suspect that in your examples, NDEBUG is not set. Thus the classes and methods are added to the *debug* policy.
2. While playing with this I get crashes when I just c/p release policy and rename it, e.g. +struct my_release : basic_policy< + my_release, std_rtti, fast_perfect_hash<my_release>, + vptr_vector<my_release>,
This creates a new policy, from scratch. Its catalog of classes and methods is distinct from the debug policy's - and it's empty. You need to use my_release consistently. For example: BOOST_OPENMETHOD( poke, (std::ostream&, virtual_ptr<Animal, my_release>), void, my_release); ^^^^^^^^^^^^ ^^^^^^^^^^^^ BOOST_OPENMETHOD_CLASSES(Animal, Cat, Dog, Bulldog, my_release); ^^^^^^^^^^^^ int main() { boost::openmethod::initialize<my_release>(); ^^^^^^^^^^^^ ... } Compiler Explorer: https://godbolt.org/z/MGs1eMd8W Of course it is rather cumbersome to add the policy as a second argument to virtual_ptr everywhere. At this point, you can create an alias: template<typename T> using my_ptr = virtual_ptr<T, my_release>; BOOST_OPENMETHOD( poke, (std::ostream&, my_ptr<Animal>), void, my_release); You can also globally override the policy: #include <boost/openmethod/policies.hpp> using namespace boost::openmethod::policies; struct my_release : basic_policy< my_release, std_rtti, fast_perfect_hash<my_release>, vptr_vector<my_release>, vectored_error_handler<my_release>> {}; // BEFORE including <boost/openmethod.hpp> #define BOOST_OPENMETHOD_POLICY my_release #include <boost/openmethod.hpp>
It also exibits some other weird behavior, e.g. if I switch debug inheritance from release to my_release crash goes away, even when not using debug...
If you mean what I think ;) it is because `debug` is the default policy in the absence of NDEBUG.
Looks to me I am doing something that is not allowed, but it is not clear what I am doing wrong.
Policies and facets are definitely an advanced feature. J-L On Wed, Apr 30, 2025 at 7:36 AM Ivan Matek via Boost <boost@lists.boost.org> wrote:
Hello, I just started with review and I have a cluster of questions, but it is not clear what the root cause of my issues is so apologies if ordering of questions is wrong.
1. I wanted to get hash map stats, but they are not printed in debug policy, even when env variable is set, I must hack release policy like this: - vptr_vector<release>, vectored_error_handler<release>> {}; + vptr_vector<release>, vectored_error_handler<release>, basic_trace_output<release>> {} Is this expected? IDK why debug prints some trace, but not hash info
2. While playing with this I get crashes when I just c/p release policy and rename it, e.g. +struct my_release : basic_policy< + my_release, std_rtti, fast_perfect_hash<my_release>, + vptr_vector<my_release>, vectored_error_handler<my_release>> {}; crashes in template<bool Indirect> inline auto box_vptr(const vptr_type& vp) { if constexpr (Indirect) { return &vp; } else { return vp; } } but when I switch
boost::openmethod::initialize<boost::openmethod::policies::my_release>(); to
boost::openmethod::initialize<boost::openmethod::policies::release>();
it works fine. It also exibits some other weird behavior, e.g. if I switch debug inheritance from release to my_release crash goes away, even when not using debug...
Looks to me I am doing something that is not allowed, but it is not clear what I am doing wrong.
regards, Ivan
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost