mercredi 2 septembre 2015

How to deal with `boost::detail::variant::void_` spam in error messages?

C++ template error messages are notoriously hard to read sometimes, however in a project I am working on the problem is greatly aggravated by the fact that when I use boost::variant the type seems to get padded out by 17 copies of the type boost::detail::variant::void_. The error messages would be much easier to read I think if I could cut out that cruft.

Example backtrace:

#8  0x00000000018538fc in std::allocator_traits<std::allocator<boost::variant<std::string, quoted_string, boost::recursive_wrapper<macro_syntax>, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> > >::allocate(std::allocator<boost::variant<std::string, quoted_string, boost::recursive_wrapper<macro_syntax>, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> >&, unsigned long) ()
#9  0x00000000018538a6 in std::_Vector_base<boost::variant<std::string, quoted_string, boost::recursive_wrapper<macro_syntax>, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>, std::allocator<boost::variant<std::string, quoted_string, boost::recursive_wrapper<macro_syntax>, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> > >::_M_allocate(unsigned long) ()
#10 0x000000000185383f in std::_Vector_base<boost::variant<std::string, quoted_string, boost::recursive_wrapper<macro_syntax>, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>, std::allocator<boost::variant<std::string, quoted_string, boost::recursive_wrapper<macro_syntax>, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> > >::_M_create_storage(unsigned long) ()

A few possible resolutions come to mind:

  1. Adjust a macro or template parameter exposed by boost (does it exist?) such that boost::variant is limited to contain only 5 or 6 types and doesn't pad itself out with so much void_ cruft.

  2. Typedef boost::variant::detail::void_ to something with a really short name, or even just a series of underscores, and somehow convince the compiler to use that name instead in the error messages.

  3. Run all the compiler error messages through a program, maybe even just a sed script, that chops out instances of string , boost::detail::variant::void_

Which of these, if any, work / is the best? Is there a better way I didn't think of / don't know about?

Aucun commentaire:

Enregistrer un commentaire