<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://baszerr.eu/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>BaSzErr - blog:2016:05:18</title>
        <description></description>
        <link>https://baszerr.eu/</link>
        <lastBuildDate>Sun, 05 Apr 2026 14:49:15 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://baszerr.eu/lib/exe/fetch.php?media=wiki:dokuwiki.svg</url>
            <title>BaSzErr</title>
            <link>https://baszerr.eu/</link>
        </image>
        <item>
            <title>c_and_function_signatures</title>
            <link>https://baszerr.eu/doku.php?id=blog:2016:05:18:c_and_function_signatures</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;c_and_function_signatures&quot;&gt;2016-05-18 - C++ and function signatures&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
&lt;a href=&quot;https://en.wikipedia.org/wiki/C++&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/C++&quot;&gt;C++&lt;/a&gt; is complex. i constantly get surprised by corner cases. few days back &lt;a href=&quot;https://en.wikipedia.org/wiki/http://szborows.blogspot.cz&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/http://szborows.blogspot.cz&quot;&gt;Sławek&lt;/a&gt; asked me if i know, if return type of a function is a part of a function&amp;#039;s signature. i said “no” and he replied “well – i though so too”. it runs out that the correct answer is… “it depends”. let&amp;#039;s have a look at some examples:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; f1&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
template&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;typename T&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; f2&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
template&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;typename T&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; A
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  template&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;typename U&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; f3&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
template&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;typename T&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; B
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; f4&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; foo&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  f1&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  f2&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;double&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  A&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;double&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt; a&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  a.&lt;span class=&quot;me1&quot;&gt;f3&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;double&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  B&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;double&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt; b&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  b.&lt;span class=&quot;me1&quot;&gt;f4&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
now let&amp;#039;s see what&amp;#039;s the compiler&amp;#039;s output:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;clang++ &lt;span class=&quot;re5&quot;&gt;-Wall&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-std&lt;/span&gt;=c++&lt;span class=&quot;nu0&quot;&gt;14&lt;/span&gt; syms.cpp &lt;span class=&quot;re5&quot;&gt;-c&lt;/span&gt;
&lt;span class=&quot;kw2&quot;&gt;nm&lt;/span&gt; syms.o &lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt; c++filt  &lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;grep&lt;/span&gt; U&lt;/pre&gt;

&lt;p&gt;
and we get:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;   U f1(int)
   U int f2&amp;lt;double&amp;gt;(int)
   U int A&amp;lt;double&amp;gt;::f3&amp;lt;double&amp;gt;(int)
   U B&amp;lt;double&amp;gt;::f4(int)&lt;/pre&gt;

&lt;p&gt;
note that &lt;em&gt;f2&lt;/em&gt; and &lt;em&gt;f3&lt;/em&gt; do have return types in their signatures, while &lt;em&gt;f1&lt;/em&gt; and &lt;em&gt;f4&lt;/em&gt; don&amp;#039;t!
&lt;/p&gt;

&lt;p&gt;
as usually – that&amp;#039;s the corner case in the C++ &lt;abbr title=&quot;specification&quot;&gt;spec&lt;/abbr&gt;. looking at &lt;a href=&quot;https://en.wikipedia.org/wiki/C++14&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/C++14&quot;&gt;C++14&lt;/a&gt; &lt;abbr title=&quot;specification&quot;&gt;spec&lt;/abbr&gt; 1.3.17 through 1.3.22, explains the secret:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; 1.3.17 – &lt;em&gt;function&lt;/em&gt;: name, parameter type list (8.3.5), and enclosing namespace (if any).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; 1.3.18 – &lt;em&gt;function template&lt;/em&gt;: name, parameter type list (8.3.5), enclosing namespace (if any), &lt;strong&gt;return type&lt;/strong&gt;, and template parameter list.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; 1.3.19 – &lt;em&gt;function template specialization&lt;/em&gt;: signature of the &lt;strong&gt;template of which it is a specialization&lt;/strong&gt; and its template arguments (whether explicitly specified or deduced).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; 1.3.20 – &lt;em&gt;class member function&lt;/em&gt;: name, parameter type list (8.3.5), class of which the function is a member, cv-qualifiers (if any), and ref-qualifier (if any)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; 1.3.21 – &lt;em&gt;class member function template&lt;/em&gt;: name, parameter type list (8.3.5), class of which the function is a member, cv-qualifiers (if any), ref-qualifier (if any), &lt;strong&gt;return type&lt;/strong&gt;, and template parameter list&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; 1.3.22 – &lt;em&gt;class member function template specialization&lt;/em&gt;: signature of the member function &lt;strong&gt;template of which it is a specialization&lt;/strong&gt; and its template arguments (whether explicitly specified or deduced).&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
long story  short – if you have a template (member) function (partial) (specialization), return type &lt;em class=&quot;u&quot;&gt;is&lt;/em&gt; a part of the signature. otherwise &lt;em class=&quot;u&quot;&gt;its not&lt;/em&gt;.
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 15 Jun 2021 20:09:21 +0000</pubDate>
        </item>
    </channel>
</rss>
