• Jason Rhinelander's avatar
    Track registered instances that share a pointer address · 1b05ce5b
    Jason Rhinelander authored
    The pointer to the first member of a class instance is the same as the
    pointer to instance itself; pybind11 has some workarounds for this to
    not track registered instances that have a registered parent with the
    same address.  This doesn't work everywhere, however: issue #328 is a
    failure of this for a mutator operator which resolves its argument to
    the parent rather than the child, as is needed in #328.
    
    This commit resolves the issue (and restores tracking of same-address
    instances) by changing registered_instances from an unordered_map to an
    unordered_multimap that allows duplicate instances for the same pointer
    to be recorded, then resolves these differences by checking the type of
    each matched instance when looking up an instance.  (A
    unordered_multimap seems cleaner for this than a unordered_map<list> or
    similar because, the vast majority of the time, the instance will be
    unique).
    1b05ce5b
issues.ref 1.2 KB