Boost C++ Libraries: Ticket #12788: optional 1.63 no longer can be initialized from '<brace-enclosed initializer list>' https://svn.boost.org/trac10/ticket/12788 <p> The code below compiles fine with boost.1.62 - but it can't compile with boost1.63: </p> <pre class="wiki"> struct S { int a; int b; }; boost::optional&lt;S&gt; so; so = {1,2}; </pre><p> With error: </p> <p> error: no match for 'operator=' (operand types are 'boost::optional&lt;S&gt;' and '&lt;brace-enclosed initializer list&gt;') </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12788 Trac 1.4.3 piotrwn1@… Mon, 30 Jan 2017 13:54:01 GMT <link>https://svn.boost.org/trac10/ticket/12788#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12788#comment:1</guid> <description> <p> To clarify: compiled with gcc5.3 with -std=c++14 </p> </description> <category>Ticket</category> </item> <item> <author>piotrwn1@…</author> <pubDate>Mon, 30 Jan 2017 15:44:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12788#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12788#comment:2</guid> <description> <p> Demo: <a class="ext-link" href="http://melpon.org/wandbox/permlink/hwZZLl23nMcb3bs4"><span class="icon">​</span>http://melpon.org/wandbox/permlink/hwZZLl23nMcb3bs4</a> </p> </description> <category>Ticket</category> </item> <item> <author>rschiele@…</author> <pubDate>Thu, 02 Feb 2017 13:31:07 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12788#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12788#comment:3</guid> <description> <p> Note that you can get the old behavior back by defining BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX for your code. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>akrzemi1</dc:creator> <pubDate>Fri, 24 Feb 2017 13:23:10 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/12788#comment:4 https://svn.boost.org/trac10/ticket/12788#comment:4 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Fernando Cacciola</span> to <span class="trac-author">akrzemi1</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket akrzemi1 Fri, 24 Feb 2017 13:37:41 GMT status changed; cc, resolution set https://svn.boost.org/trac10/ticket/12788#comment:5 https://svn.boost.org/trac10/ticket/12788#comment:5 <ul> <li><strong>cc</strong> <span class="trac-author">akrzemi1</span> added </li> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> This breakage is intentional. </p> <p> In fact the previous behavior was inconsistent with <code>std::optional</code> and error-prone. Braces should deduce type <code>optional&lt;T&gt;</code>, not to <code>T</code>. For more details of why it was confusing, see here: </p> <blockquote> <p> <a class="ext-link" href="http://stackoverflow.com/questions/40391244/difference-between-boost-optional-and-stdexperimental-optional-assignment/40677193#40677193"><span class="icon">​</span>http://stackoverflow.com/questions/40391244/difference-between-boost-optional-and-stdexperimental-optional-assignment/40677193#40677193</a> </p> </blockquote> <p> Now the following puts the optional into no-value state: </p> <pre class="wiki">boost::optional&lt;S&gt; so; so = {}; </pre><p> Just like <code>std::optional</code>. </p> Ticket piotrwn1@… Sun, 26 Feb 2017 13:09:37 GMT <link>https://svn.boost.org/trac10/ticket/12788#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12788#comment:6</guid> <description> <p> Well, the OP problem was not with empty braces. </p> </description> <category>Ticket</category> </item> <item> <author>piotrwn1@…</author> <pubDate>Mon, 27 Feb 2017 11:43:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12788#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12788#comment:7</guid> <description> <p> This is real problem, please do not close. </p> <p> See this code: </p> <pre class="wiki">#include &lt;boost/optional.hpp&gt; #include &lt;optional&gt; #include &lt;iostream&gt; #define PRN(a) std::cout &lt;&lt; #a "\n"; #define DEF(a, r) a { PRN(a); r } struct Verbose { DEF(Verbose(int,double),) DEF(Verbose(),) DEF(~Verbose(),) DEF(Verbose(const Verbose&amp;),) DEF(Verbose(Verbose&amp;&amp;),) DEF(Verbose&amp; operator = (const Verbose&amp;), return *this;) DEF(Verbose&amp; operator = (Verbose&amp;&amp;), return *this;) }; using vbo = boost::optional&lt;Verbose&gt;; using vso = std::optional&lt;Verbose&gt;; int main() { vbo bo; vso so; bo = {1,1.1}; // works for boost1.62, not for boost.1.63 so = {1,1.1}; // works for std::optional } </pre><p> Link do demo: <a class="ext-link" href="http://melpon.org/wandbox/permlink/wDvuR7T9b7bI5fHq"><span class="icon">​</span>http://melpon.org/wandbox/permlink/wDvuR7T9b7bI5fHq</a> </p> </description> <category>Ticket</category> </item> <item> <author>piotrwn1@…</author> <pubDate>Mon, 27 Feb 2017 11:44:25 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/12788#comment:8 https://svn.boost.org/trac10/ticket/12788#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> Ticket Jürgen Hunold Fri, 07 Apr 2017 07:50:03 GMT <link>https://svn.boost.org/trac10/ticket/12788#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12788#comment:9</guid> <description> <p> Create an auto test from the example </p> <p> See <a class="ext-link" href="https://github.com/boostorg/optional/pull/28"><span class="icon">​</span>https://github.com/boostorg/optional/pull/28</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>