[Boost-bugs] [Boost C++ Libraries] #13518: Default constructor is explicit, no reason to be.

Subject: [Boost-bugs] [Boost C++ Libraries] #13518: Default constructor is explicit, no reason to be.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-04-13 11:15:00

#13518: Default constructor is explicit, no reason to be.
 Reporter: anonymous | Owner: Joaquín M López Muñoz
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: multi_index
  Version: Boost 1.66.0 | Severity: Problem
 Keywords: |
 See the follwing code
 #include <boost/multi_index_container.hpp>
 #include <boost/multi_index/ordered_index.hpp>
 #include <boost/multi_index/identity.hpp>

 using namespace std;

 struct aggregate {
         boost::multi_index_container<int> a;

 int main()
         using boost::multi_index_container;
         multi_index_container<int> a; // default init
         // multi_index_container<int> b(); // NOT A THING, not object init
         multi_index_container<int> c =
                 multi_index_container<int>(); //value init + (elided) copy

         auto d = multi_index_container<int>(); // value init + (elided)

         multi_index_container<int> e{}; // direct-list-init, chooses value

         auto f = multi_index_container<int>{};
         // direct-list-init, chooses value init
         // followed by elided copy

         multi_index_container<int> g = {}; // ERROR
         // copy-list-init, should choose value init
         // but fails becase default constructor is explicit

         aggregate agg1{}; // ERROR for the same reason above
         aggregate agg2 = {}; // ERROR for the same reason above
         // Does aggregate init which does copy-list-init on members that
         // were not specified in the list.

         auto agg3 = aggregate(); //OK, value init

         multi_index_container<int> h{1, 2, 3, 4};
         // direct-list-init, chooses initializer list

         multi_index_container<int> i = {1, 2, 3, 4};
         // copy-list-init, chooses initializer list
         return 0;

 The problematic ctor is in line 175 of multi_index_container.hpp
   explicit multi_index_container(

     /* VisualAge seems to have an ETI issue with the default values
      * for arguments args_list and al.

     const ctor_args_list& args_list=
       typename mpl::identity<multi_index_container>::type::
     const allocator_type& al=
       typename mpl::identity<multi_index_container>::type::
     const ctor_args_list& args_list=ctor_args_list(),
     const allocator_type& al=allocator_type()):

 Probably, it was made explicit for the case when it is called with non-
 default parameters.

Ticket URL: <https://svn.boost.org/trac10/ticket/13518>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2018-04-13 11:22:08 UTC