Boost C++ Libraries: Ticket #10439: Flyweight: now the constructor is explicit https://svn.boost.org/trac10/ticket/10439 <p> Hi, </p> <p> The following piece of code used to work fine, but with 1.56, it now fails to compile with the two major free compilers. </p> <p> Thanks! </p> <pre class="wiki">$ cat /tmp/foo.cc #include &lt;string&gt; #include &lt;boost/flyweight.hpp&gt; int main() { boost::flyweight&lt;std::string&gt; f = {}; } $ clang++-mp-3.5 -std=c++11 -I /opt/local/include foo.cc foo.cc:6:33: error: chosen constructor is explicit in copy-initialization boost::flyweight&lt;std::string&gt; f = {}; ^ ~~ /opt/local/include/boost/flyweight/flyweight.hpp:195:14: note: constructor declared here explicit flyweight, ^ /opt/local/include/boost/flyweight/detail/perfect_fwd.hpp:79:27: note: expanded from macro 'BOOST_FLYWEIGHT_PERFECT_FWD' template&lt;typename... Args&gt;name(Args&amp;&amp;... args) \ ^ 1 error generated. $ g++-mp-4.9 -std=c++11 -I /opt/local/include foo.cc foo.cc: In function 'int main()': foo.cc:6:38: error: converting to 'boost::flyweights::flyweight&lt;std::basic_string&lt;char&gt; &gt;' from initializer list would use explicit constructor 'boost::flyweights::flyweight&lt;T, Arg1, Arg2, Arg3, Arg4, Arg5&gt;::flyweight(Args&amp;&amp; ...) [with Args = {}; T = std::basic_string&lt;char&gt;; Arg1 = boost::parameter::void_; Arg2 = boost::parameter::void_; Arg3 = boost::parameter::void_; Arg4 = boost::parameter::void_; Arg5 = boost::parameter::void_]' boost::flyweight&lt;std::string&gt; f = {}; ^ </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10439 Trac 1.4.3 Akim Demaille <akim.demaille@…> Mon, 01 Sep 2014 09:10:44 GMT <link>https://svn.boost.org/trac10/ticket/10439#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10439#comment:1</guid> <description> <p> The following also used to work up to 1.55, and is now broken. </p> <pre class="wiki">$ cat foo.cc #include &lt;string&gt; #include &lt;boost/flyweight.hpp&gt; using string = boost::flyweight&lt;std::string&gt;; void foo(string) {} int main() { foo({}); } $ clang++-mp-3.5 -std=c++11 -I /opt/local/include foo.cc foo.cc:10:3: error: no matching function for call to 'foo' foo({}); ^~~ foo.cc:6:6: note: candidate function not viable: cannot convert initializer list argument to 'string' (aka 'flyweight&lt;std::string&gt;') void foo(string) {} ^ 1 error generated. $ g++-mp-4.9 -std=c++11 -I /opt/local/include foo.cc foo.cc: In function 'int main()': foo.cc:10:9: error: converting to 'string {aka boost::flyweights::flyweight&lt;std::basic_string&lt;char&gt; &gt;}' from initializer list would use explicit constructor 'boost::flyweights::flyweight&lt;T, Arg1, Arg2, Arg3, Arg4, Arg5&gt;::flyweight(Args&amp;&amp; ...) [with Args = {}; T = std::basic_string&lt;char&gt;; Arg1 = boost::parameter::void_; Arg2 = boost::parameter::void_; Arg3 = boost::parameter::void_; Arg4 = boost::parameter::void_; Arg5 = boost::parameter::void_]' foo({}); ^ </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Joaquín M López Muñoz</dc:creator> <pubDate>Fri, 05 Sep 2014 10:12:08 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10439#comment:2 https://svn.boost.org/trac10/ticket/10439#comment:2 <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/flyweight/commit/20230d966942fa4bfddba3a2b8fea0cd26eee6d4"><span class="icon">​</span>https://github.com/boostorg/flyweight/commit/20230d966942fa4bfddba3a2b8fea0cd26eee6d4</a> </p> <p> I'd appreciate if you could test the fix works for you. </p> Ticket Akim Demaille <akim.demaille@…> Tue, 16 Sep 2014 13:30:40 GMT <link>https://svn.boost.org/trac10/ticket/10439#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10439#comment:3</guid> <description> <p> Hi Joaquin, </p> <p> Thanks for the quick fix. Yes, I can confirm that it fixed my issue. FWIW, I have also observe a 20% speed up of my parsing routines (from 1.55 to 1.56), that use flyweight for identifiers. Nice! </p> </description> <category>Ticket</category> </item> </channel> </rss>