initializer_list
When using Boost.JSON I stumbled upon the following issue:
boost::json::value jv(1); // creates a number type
boost::json::value jv{1}; // creates an array type
The JSON value object has constructor definitions something like these:
struct value
{
value(int);
value(double);
value(std::initializer_list<int>);
};
This gives the following invocations:
value vl1(1); // invokes value(int) constructor
value vl2{1}; // invokes value(std::initializer_list<int>); constructor
This is a know issue in C++. A programming language should be unambiguously be interpretable and the C++ had decided that in such case the initializer_list has precedence. Not sure if that's a good solution since the ambiguity may only appear when running under the debugger or at customer site. The ambiguity can be solved by requiring double braces in case there are overloads like this but the all wise C++ committee has decided otherwise. The uniform initialization problem is still not solved.
Edit: this behavior has now been patched as of Boost 1.86. If the initializer_list has size 1 it's assumed to be a single value type instead of array. Original behavior can be mimicked by using BOOST_JSON_LEGACY_INIT_LIST_BEHAVIOR. Pretty smart trick t.b.h.