<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Initializer_list on Cheat Sheet</title><link>/tags/initializer_list/</link><description>Recent content in Initializer_list on Cheat Sheet</description><generator>Hugo</generator><language>en</language><atom:link href="/tags/initializer_list/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><item><title>Functions</title><link>/programming/cpp/primer/functions/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/programming/cpp/primer/functions/</guid><description>&lt;h1 id="functions"&gt;Functions&lt;a class="anchor" href="#functions"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Based on &lt;em&gt;C++ Primer, 5th ed.&lt;/em&gt; Chapter 6 (Functions).&lt;/p&gt;
&lt;p&gt;A function is a block of code with a name. Functions can be overloaded, meaning that the same name may refer to several different functions.&lt;/p&gt;
&lt;h2 id="1-object-lifetime-and-function-declarations"&gt;1. Object Lifetime and Function Declarations&lt;a class="anchor" href="#1-object-lifetime-and-function-declarations"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id="automatic-objects"&gt;Automatic Objects&lt;a class="anchor" href="#automatic-objects"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;An automatic object is an object that exists only while a block is executing.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Parameters are automatic objects.&lt;/strong&gt; They are created (initialized) when the function is called and destroyed when the block is exited.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="local-static-objects"&gt;Local &lt;code&gt;static&lt;/code&gt; Objects&lt;a class="anchor" href="#local-static-objects"&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Each local &lt;code&gt;static&lt;/code&gt; object is initialized before the first time execution passes through the object&amp;rsquo;s definition.&lt;/p&gt;</description></item></channel></rss>