
On Wed, Apr 30, 2025 at 4:32 PM Jean-Louis Leroy via Boost < boost@lists.boost.org> wrote:
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/f...
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>;
Hi, thank you for the answer, review branch prints out hashing stats. Few follow up questions. 1. Why virtual_ptr doesn't just pick up the policy that was used in initialize? I presume to avoid some runtime performance overhead. 2. Should this behavior be more explicitly mentioned in the documentation. I was reading documentation and assumed I can just provide my policy in initialize, it was not clear to me what you explained here. I mean now I know how things work it is obvious https://jll63.github.io/Boost.OpenMethod/#tutorials_policies_and_facets is mentioning that initialize and virtual_ptr are "linked", but I think it is not obvious when reading it for the first time. 3. Why are we breaking here out of just 1 for loop? https://github.com/jll63/Boost.OpenMethod/blob/4e4dff8059f94b07c201036c0e918...