Boost-Pretty-Printer icon indicating copy to clipboard operation
Boost-Pretty-Printer copied to clipboard

Minimal support for boost::type_erasure::any.

Open redboltz opened this issue 6 years ago • 1 comments

Just print the address of actual data.

You can get outputs as follows:

(gdb) p multi_index_container
$1 = boost::type_erasure::any<...> data = 0x555555571f10

If you know the acutual type, then you can cast as follows:

(gdb) p *(ActualType)0x555555571f10

redboltz avatar Aug 06 '19 06:08 redboltz

When I use boost::type_erasure::any<...>, especially as the member of the container, I got annoying outputs as follows:

boost::type_erasure::any_constructor_control<boost::type_erasure::any_constructor_impl<boost::mpl::vector<boost::type_erasure::copy_constructible<boost::type_erasure::_self>, has_foo<void () const, boost::type_erasure::_self>, has_get<int () const, boost::type_erasure::_self>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self>, void>> = {
    <boost::type_erasure::any_constructor_impl<boost::mpl::vector<boost::type_erasure::copy_constructible<boost::type_erasure::_self>, has_foo<void () const, boost::type_erasure::_self>, has_get<int () const, boost::type_erasure::_self>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self

This PR suppress the annoying outputs and print the address of the data that is owned by boost::type_erasure::any<...>.

User can cast the address as the actual type. Gdb can't get the actual type because type is erased. So user needs to do try and error the possible types. I think that it is good enough.

redboltz avatar Aug 06 '19 06:08 redboltz