<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>In-Class Initializer on Cheat Sheet</title><link>/tags/in-class-initializer/</link><description>Recent content in In-Class Initializer on Cheat Sheet</description><generator>Hugo</generator><language>en</language><atom:link href="/tags/in-class-initializer/index.xml" rel="self" type="application/rss+xml"/><item><title>Most Vexing Parse &amp; In-Class Initializer</title><link>/programming/cpp/most-vexing-parse/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/programming/cpp/most-vexing-parse/</guid><description>&lt;h1 id="most-vexing-parse--in-class-initializer"&gt;Most Vexing Parse &amp;amp; In-Class Initializer&lt;a class="anchor" href="#most-vexing-parse--in-class-initializer"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;This page covers the exact conditions that trigger the &lt;strong&gt;Most Vexing Parse&lt;/strong&gt; when initializing objects with &lt;code&gt;()&lt;/code&gt; in C++, contrasts it with the rule that &lt;strong&gt;prohibits &lt;code&gt;()&lt;/code&gt; altogether for in-class member initializers&lt;/strong&gt;, and explains the &lt;strong&gt;&lt;code&gt;std::initializer_list&lt;/code&gt; constructor hijacking pitfall&lt;/strong&gt; when using braces &lt;code&gt;{}&lt;/code&gt; as a workaround.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-what-is-the-most-vexing-parse"&gt;1. What Is the Most Vexing Parse?&lt;a class="anchor" href="#1-what-is-the-most-vexing-parse"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Coined by Scott Meyers in &lt;em&gt;Effective STL&lt;/em&gt; (Item 6), the &lt;strong&gt;Most Vexing Parse&lt;/strong&gt; refers to a counterintuitive consequence of C++&amp;rsquo;s syntactic disambiguation rule where &lt;strong&gt;code intended to instantiate an object using &lt;code&gt;()&lt;/code&gt; is instead parsed by the compiler as a function declaration&lt;/strong&gt;.&lt;/p&gt;</description></item></channel></rss>