[Boost][Container] Why is flat_set default constructor explicit?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Boost][Container] Why is flat_set default constructor explicit?

Boost - Users mailing list
Hi all,

I just found out that all Boost.Container default constructors are implicit (just as I would expect) except for flat_set.

Quoting from [1]:
explicit flat_set() noexcept(/*snip*/);
Effects: Default constructs an empty container.

Why is flat_set different than the other containers?
Is this an oversight?

FWIW this issue is breaking my C++14 code (for both clang and gcc) when switching from std::set to boost::container::flat_set, minimal repro follows:

#include <boost/container/flat_set.hpp>
#include <set>

#ifndef USE_STD_SET
using S = boost::container::flat_set<int>;
#else
using S = std::set<int>;
#endif

struct A
{
    int i;
    S s;
};

int main()
{
    A a1;               // OK
    A a2 {0, {{}} };    // OK

    A b1 {};            // FAILS
    A b2 {0};           // FAILS
    A b3 {0, {}};       // FAILS    
}

A f()
{
    return {};          // FAILS
}

Using Bost 1.64.0 in case that matters.
Any help appreciated.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [Boost][Container] Why is flat_set default constructor explicit?

Boost - Users mailing list
On 17/08/2017 17:02, dariomt--- via Boost-users wrote:
> Hi all,
>
> I just found out that all Boost.Container default constructors are
> implicit (just as I would expect) except for flat_set.

It's a bug introduced when a single constructor with default arguments
was split in multiple constructors. Fixed in:

https://github.com/boostorg/container/commit/863b6e0d3246a1db225675710c34adf45e63de3f

Many thanks.

Ion
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users