<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Isaac JL</title>
    <description>The latest articles on DEV Community by Isaac JL (@ijens1).</description>
    <link>https://dev.to/ijens1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F125488%2F1f41ae90-4c9a-426f-b50e-a63903ea0d16.png</url>
      <title>DEV Community: Isaac JL</title>
      <link>https://dev.to/ijens1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ijens1"/>
    <language>en</language>
    <item>
      <title>He's Back</title>
      <dc:creator>Isaac JL</dc:creator>
      <pubDate>Tue, 08 Jan 2019 03:05:29 +0000</pubDate>
      <link>https://dev.to/ijens1/hes-back-3n01</link>
      <guid>https://dev.to/ijens1/hes-back-3n01</guid>
      <description>&lt;p&gt;So it's been a couple days. Not a daily habit yet. Seems like a good thing to&lt;br&gt;
do though, so I'll do my best to stick with it.&lt;/p&gt;

&lt;p&gt;What have I done since the last post.&lt;/p&gt;

&lt;p&gt;I've started worked on the Zip project. I will admit though that I haven't been&lt;br&gt;
on top of the C++ reading. Just moved to a new place so I've been a little&lt;br&gt;
caught up in that. The zip project though is going decently so far. I've&lt;br&gt;
implemented the basic huffman compression algorithm.&lt;/p&gt;

&lt;p&gt;I created my own special magic number that of course spells out my initials,&lt;br&gt;
IDJL. After that, I store the size of the uncompressed file as an 8 byte value. Then comes the compressed tree. 0 represents a parent node and 1 represents a leaf node (after a 1, I then store the character at that leaf in a byte). An important note that I had to think about so that I could understand how this compression was valid is that a parent node is guaranteed to have two children (i.e. the tree is 'full'; a node has either 0 or 2 children).&lt;/p&gt;

&lt;p&gt;Then comes the compressed data. I struggled with figuring out how to output&lt;br&gt;
bit by bit in C++. I then came to the conclusion that you simply format it byte by byte and forfeit adding a couple extra bits at the end (max 7 extra bits).&lt;br&gt;
This is possibly one of the reasons to have the uncompressed file size. Either way, that's what I'll be using it for.&lt;/p&gt;

&lt;p&gt;And that's it so far. Next step will just be to hook it up to the display&lt;br&gt;
service so that the executable displays statuses as the file is compressed.&lt;br&gt;
Of course after that it will be decompression. I was also thinking about&lt;br&gt;
implementing arithmetic coding. I've seen that around and it's piqued my&lt;br&gt;
curiousity. We'll have to see though. I'm trying to get back on the Andrew Ng&lt;br&gt;
ML course that I started a while back. Goal is to have at least the first week&lt;br&gt;
reviewed by this weekend. I'll try to continue reading the Effective Modern C++ book on the side if I have time; it will be useful eventually.&lt;/p&gt;

&lt;p&gt;I am flitting back and forth between projects. Hopefully I can relax that habit this term and just get the main goals done (Zip project&lt;br&gt;
and ML course). We'll see what I can do. That's all for now.&lt;/p&gt;

&lt;p&gt;Oh wait yeah how could I forget. Had my first day at Ritual today. Very&lt;br&gt;
interesting place. Very different than Shopify in many ways, including&lt;br&gt;
development. Definitely less hand-holding on the first day which I found quite refreshing. Maybe that will come during orientation next week. Either way, I think there is some serious potential here to have some real impact.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>First Post, Motivations, Some Notes</title>
      <dc:creator>Isaac JL</dc:creator>
      <pubDate>Thu, 03 Jan 2019 18:14:38 +0000</pubDate>
      <link>https://dev.to/ijens1/first-post-motivations-some-notes-1khe</link>
      <guid>https://dev.to/ijens1/first-post-motivations-some-notes-1khe</guid>
      <description>&lt;h1&gt;
  
  
  First Post
&lt;/h1&gt;

&lt;p&gt;Hi there.&lt;/p&gt;

&lt;p&gt;I've spent the morning looking for something like this and I'm glad to have found it. Never done any writing before, so this is my First Post.&lt;/p&gt;

&lt;h1&gt;
  
  
  Motivations
&lt;/h1&gt;

&lt;p&gt;I want to document the things I'm doing on a daily basis and the things that I'm learning. So these are my Motivations.&lt;/p&gt;

&lt;h1&gt;
  
  
  Notes
&lt;/h1&gt;

&lt;p&gt;And for the Notes, I'm just going to dive right into content that I'm learning&lt;br&gt;
about right now, and review some items from Scott Meyers's Effective Modern C++. Keep in mind that as his descriptions are more informal, mine will tend to be as well, and I will most likely be very close in wording to what he has in the text. Also note that I will be reading the items in chronological order so I may come back to some posts to make edits and add notes about new things I learned later on.&lt;/p&gt;

&lt;p&gt;So that this review is effective for me, I'm going to write as much as possible from memory and understanding, and then make it explicitly clear in the blog when I made reference to the text using the following format:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RSB&lt;/strong&gt; &lt;em&gt;Content that I did not recall and sourced entirely from the text&lt;/em&gt; &lt;strong&gt;RSE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;and&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RCB&lt;/strong&gt; &lt;em&gt;Content that I was unsure of and needed to use the text to confirm&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;RCE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All content outside of these 'reference parentheses' is entirely from memory.&lt;/p&gt;

&lt;p&gt;Let's go.&lt;/p&gt;
&lt;h3&gt;
  
  
  First Review Item
&lt;/h3&gt;

&lt;p&gt;How template type deduction works. There are three cases&lt;br&gt;
that will allow you to deduce what &lt;code&gt;T&lt;/code&gt; is in the templated function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ParamType&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Each case relies on the form of &lt;code&gt;ParamType&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;ParamType&lt;/code&gt; is a reference or a pointer &lt;strong&gt;RSB&lt;/strong&gt; and not
a universal reference &lt;strong&gt;RSE&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ParamType&lt;/code&gt; is  &lt;strong&gt;RCB&lt;/strong&gt; a universal reference &lt;strong&gt;RCE&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ParamType&lt;/code&gt; is neither a reference nor a pointer.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Case 1
&lt;/h4&gt;

&lt;p&gt;In this case you follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If &lt;code&gt;expr&lt;/code&gt; is a reference, ignore the reference part.&lt;/li&gt;
&lt;li&gt;Use the classic inspection technique (Meyers calls it pattern matching) to
figure out what T should be.&lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;
  
  
  Example
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;r_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;rc_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Since x is not a reference, nothing to ignore,&lt;/span&gt;
      &lt;span class="c1"&gt;// By inspection, we can determine that T must be int&lt;/span&gt;

&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r_x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Since r_x is a reference, we ignore the reference part,&lt;/span&gt;
        &lt;span class="c1"&gt;// Then by inspection, we again determine that T must be int&lt;/span&gt;

&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rc_x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Since rc_x is a reference, we ignore the reference part,&lt;/span&gt;
         &lt;span class="c1"&gt;// Then by inspection, we determine that T must be const int&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Case 2
&lt;/h4&gt;

&lt;p&gt;In this case, you follow these guidelines:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If &lt;code&gt;expr&lt;/code&gt; is an lvalue, then both &lt;code&gt;ParamType&lt;/code&gt; and &lt;code&gt;T&lt;/code&gt; are of type lvalue
reference. Note that this is strange for them &lt;strong&gt;both&lt;/strong&gt; to be lvalue
references.&lt;/li&gt;
&lt;li&gt;If &lt;code&gt;expr&lt;/code&gt; is an rvalue, then follow case 1 rules&lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;
  
  
  Example
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;r_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;rc_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// x is an lvalue here, so T is int&amp;amp; and ParamType is also int&amp;amp;&lt;/span&gt;

&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r_x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// r_x is an lvalue, so T and ParamType are int&amp;amp;&lt;/span&gt;

&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rc_x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// rc_x is an lvalue, so T and ParamType are const int&amp;amp;&lt;/span&gt;

&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 27 is an rvalue, so we follow case 1 rules to determine that T should&lt;/span&gt;
       &lt;span class="c1"&gt;// be int and so ParamType is RSB int&amp;amp;&amp;amp; RSE.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Case 3
&lt;/h4&gt;

&lt;p&gt;In this case, we follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ignore reference.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RCB&lt;/strong&gt; Ignore any cv qualifiers &lt;strong&gt;RCE&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;
  
  
  Example
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;c_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;rc_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// T and ParamType are int&lt;/span&gt;

&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c_x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Ignore the const, so T and ParamType are int&lt;/span&gt;

&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rc_x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Ignore the reference, then the const, so T and ParamType are int.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, we're done with the cases, but Meyers continues on with some other notes&lt;br&gt;
relating to arrays decaying to pointers and functions decaying to function&lt;br&gt;
pointers.&lt;/p&gt;
&lt;h5&gt;
  
  
  Arrays decaying to pointers
&lt;/h5&gt;

&lt;p&gt;&lt;strong&gt;RSB&lt;/strong&gt;&lt;br&gt;
Meyers notes that we often believe that pointers and arrays are&lt;br&gt;
interchangeable, according to the following examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Example 1&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;param&lt;/span&gt;&lt;span class="p"&gt;[]);&lt;/span&gt;

&lt;span class="c1"&gt;// The above declaration is actually equivalent to this declaration using a pointer&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;param&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Example 2&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;important_numbers&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;125&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;ptr_to_important_numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;important_numbers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// array decays to pointer&lt;/span&gt;

&lt;span class="c1"&gt;// Example 3 (uses important_numbers declared in previous example)&lt;/span&gt;
&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="n"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;important_numbers&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// T is deduced to be const int * here&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;However, if the form of the parameter type in a template is a reference, &lt;code&gt;T&lt;/code&gt; will&lt;br&gt;
actually be deduced to be an array of the correct type, where the type also&lt;br&gt;
includes the size of the array. So, if we modified the above Example 3 to be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="n"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;important_numbers&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;T&lt;/code&gt; would successfully be deduced to be &lt;code&gt;const int (&amp;amp;)[3]&lt;/code&gt;. This allows you to&lt;br&gt;
deduce the size of arrays at compile time interestingly enough:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;constexpr&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="kt"&gt;size_t&lt;/span&gt; &lt;span class="n"&gt;sizeOfArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;noexcept&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  Functions decaying to function pointers
&lt;/h5&gt;

&lt;p&gt;He also notes similar things that happen to functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;f1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;f2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;myFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// myFunc has type void(const char*, int)&lt;/span&gt;

&lt;span class="n"&gt;f1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myFunc&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// T is deduced to type void (*)(const char*, int)&lt;/span&gt;
&lt;span class="n"&gt;f2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myFunc&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// T is deduced to type void (&amp;amp;)(const char*, int)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
