Boost C++ Libraries: Ticket #13518: Default constructor is explicit, no reason to be. https://svn.boost.org/trac10/ticket/13518 <p> See the follwing code </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/multi_index_container.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/multi_index/ordered_index.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/multi_index/identity.hpp&gt;</span><span class="cp"></span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">std</span><span class="p">;</span> <span class="k">struct</span> <span class="n">aggregate</span> <span class="p">{</span> <span class="n">boost</span><span class="o">::</span><span class="n">multi_index_container</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">a</span><span class="p">;</span> <span class="p">};</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="k">using</span> <span class="n">boost</span><span class="o">::</span><span class="n">multi_index_container</span><span class="p">;</span> <span class="n">multi_index_container</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">a</span><span class="p">;</span> <span class="c1">// default init</span> <span class="c1">// multi_index_container&lt;int&gt; b(); // NOT A THING, not object init</span> <span class="n">multi_index_container</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">c</span> <span class="o">=</span> <span class="n">multi_index_container</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span><span class="p">();</span> <span class="c1">//value init + (elided) copy</span> <span class="k">auto</span> <span class="n">d</span> <span class="o">=</span> <span class="n">multi_index_container</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span><span class="p">();</span> <span class="c1">// value init + (elided) copy</span> <span class="n">multi_index_container</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">e</span><span class="p">{};</span> <span class="c1">// direct-list-init, chooses value init</span> <span class="k">auto</span> <span class="n">f</span> <span class="o">=</span> <span class="n">multi_index_container</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span><span class="p">{};</span> <span class="c1">// direct-list-init, chooses value init</span> <span class="c1">// followed by elided copy</span> <span class="n">multi_index_container</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">g</span> <span class="o">=</span> <span class="p">{};</span> <span class="c1">// ERROR</span> <span class="c1">// copy-list-init, should choose value init</span> <span class="c1">// but fails becase default constructor is explicit</span> <span class="n">aggregate</span> <span class="n">agg1</span><span class="p">{};</span> <span class="c1">// ERROR for the same reason above</span> <span class="n">aggregate</span> <span class="n">agg2</span> <span class="o">=</span> <span class="p">{};</span> <span class="c1">// ERROR for the same reason above</span> <span class="c1">// Does aggregate init which does copy-list-init on members that</span> <span class="c1">// were not specified in the list.</span> <span class="k">auto</span> <span class="n">agg3</span> <span class="o">=</span> <span class="n">aggregate</span><span class="p">();</span> <span class="c1">//OK, value init</span> <span class="n">multi_index_container</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">h</span><span class="p">{</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">};</span> <span class="c1">// direct-list-init, chooses initializer list</span> <span class="n">multi_index_container</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">i</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">};</span> <span class="c1">// copy-list-init, chooses initializer list</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> The problematic ctor is in line 175 of multi_index_container.hpp </p> <div class="wiki-code"><div class="code"><pre> <span class="k">explicit</span> <span class="nf">multi_index_container</span><span class="p">(</span> <span class="cp">#if BOOST_WORKAROUND(__IBMCPP__,&lt;=600)</span> <span class="cm">/* VisualAge seems to have an ETI issue with the default values</span> <span class="cm"> * for arguments args_list and al.</span> <span class="cm"> */</span> <span class="k">const</span> <span class="n">ctor_args_list</span><span class="o">&amp;</span> <span class="n">args_list</span><span class="o">=</span> <span class="k">typename</span> <span class="n">mpl</span><span class="o">::</span><span class="n">identity</span><span class="o">&lt;</span><span class="n">multi_index_container</span><span class="o">&gt;::</span><span class="n">type</span><span class="o">::</span> <span class="n">ctor_args_list</span><span class="p">(),</span> <span class="k">const</span> <span class="n">allocator_type</span><span class="o">&amp;</span> <span class="n">al</span><span class="o">=</span> <span class="k">typename</span> <span class="n">mpl</span><span class="o">::</span><span class="n">identity</span><span class="o">&lt;</span><span class="n">multi_index_container</span><span class="o">&gt;::</span><span class="n">type</span><span class="o">::</span> <span class="n">allocator_type</span><span class="p">())</span><span class="o">:</span> <span class="cp">#else</span> <span class="k">const</span> <span class="n">ctor_args_list</span><span class="o">&amp;</span> <span class="n">args_list</span><span class="o">=</span><span class="n">ctor_args_list</span><span class="p">(),</span> <span class="k">const</span> <span class="n">allocator_type</span><span class="o">&amp;</span> <span class="n">al</span><span class="o">=</span><span class="n">allocator_type</span><span class="p">())</span><span class="o">:</span> <span class="cp">#endif</span> <span class="n">bfm_allocator</span><span class="p">(</span><span class="n">al</span><span class="p">),</span> <span class="n">super</span><span class="p">(</span><span class="n">args_list</span><span class="p">,</span><span class="n">bfm_allocator</span><span class="o">::</span><span class="n">member</span><span class="p">),</span> <span class="n">node_count</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="n">BOOST_MULTI_INDEX_CHECK_INVARIANT</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> Probably, it was made explicit for the case when it is called with non-default parameters. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13518 Trac 1.4.3 Joaquín M López Muñoz Fri, 13 Apr 2018 16:12:35 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/13518#comment:1 https://svn.boost.org/trac10/ticket/13518#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed at: </p> <p> <a class="ext-link" href="https://github.com/boostorg/multi_index/commit/9623bf0a7d424575350290e121d53a891fc1c9b2"><span class="icon">​</span>https://github.com/boostorg/multi_index/commit/9623bf0a7d424575350290e121d53a891fc1c9b2</a> </p> Ticket