Skip to content

fixed [over.match.list]-related problem with eager value_type - #340

Merged
igaztanaga merged 1 commit into
boostorg:developfrom
joaquintides:feature/fix-eager-value_type-ctors
Aug 8, 2026
Merged

fixed [over.match.list]-related problem with eager value_type#340
igaztanaga merged 1 commit into
boostorg:developfrom
joaquintides:feature/fix-eager-value_type-ctors

Conversation

@joaquintides

@joaquintides joaquintides commented Aug 8, 2026

Copy link
Copy Markdown
Member

The following

#include <boost/container/hub.hpp>
#include <boost/any.hpp>

int main()
{
  boost::container::hub<boost::any> h;
}

fails in VS (and other compilers):

error C7535: 'boost::container::hub<boost::any,void>::hub': delegating constructor calls itself

This is due to a sequence of happenstances:

  • boost::container::hub default ctor delegates to hub{allocator_type()} (note the braces).
  • The braces, in connection with [over.match.list] and the fact that boost::any can be constructed from allocator_type (and from anything), make the compiler consider std::initializer_list construction.
  • std::initializer_list construction delegates to hub{il.begin(), il.end(), al_}.
  • hub{il.begin(), il.end(), al_} is again formally valid as constructing from a std::initializer_list of boost::anys, and recursion ensues.

The simple fix is replacing {...}-style construction with (...) everywhere (not only for the default constructor).

@igaztanaga
igaztanaga merged commit 937102a into boostorg:develop Aug 8, 2026
60 of 61 checks passed
@igaztanaga

Copy link
Copy Markdown
Member

Many thanks Joaquin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants