<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[friend function in decltype in trailing return type]]></title><description><![CDATA[<p>Sobald ich eine, in einer friend declaration definierte, Funktion in einem decltype in einem trailing return type verwende, liefert MSVC 11 mir folgende Fehlermeldung:</p>
<pre><code class="language-cpp">namespace math
{
  struct vector
  {
    friend float dot(const vector&amp; a, const vector&amp; b)
    {
      return 42.0f;
    }
  };

  inline auto square(const vector&amp; v) -&gt; decltype(dot(v, v))
  {
    return dot(v, v);
  }
}

int main()
{
  float l = square(math::vector());
}
</code></pre>
<p>Output:</p>
<pre><code>d:\blub\main.cpp(11): error C3767: 'dot': candidate function(s) not accessible
1&gt;          could be the friend function at 'd:\blub\main.cpp(5)' : 'dot'  [may be found via argument-dependent lookup]
</code></pre>
<p>Sobald die Funktion außerhalb des struct definiert wird, klappt alles. Hat jemand eine Erklärung dafür? Ich vermute mal, dass es sich um einen Compilerbug handelt, denn imo sollte das perfekt standardkonformer Code sein...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/307471/friend-function-in-decltype-in-trailing-return-type</link><generator>RSS for Node</generator><lastBuildDate>Tue, 25 Aug 2026 18:57:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/307471.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 27 Aug 2012 20:53:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to friend function in decltype in trailing return type on Mon, 27 Aug 2012 20:57:04 GMT]]></title><description><![CDATA[<p>Sobald ich eine, in einer friend declaration definierte, Funktion in einem decltype in einem trailing return type verwende, liefert MSVC 11 mir folgende Fehlermeldung:</p>
<pre><code class="language-cpp">namespace math
{
  struct vector
  {
    friend float dot(const vector&amp; a, const vector&amp; b)
    {
      return 42.0f;
    }
  };

  inline auto square(const vector&amp; v) -&gt; decltype(dot(v, v))
  {
    return dot(v, v);
  }
}

int main()
{
  float l = square(math::vector());
}
</code></pre>
<p>Output:</p>
<pre><code>d:\blub\main.cpp(11): error C3767: 'dot': candidate function(s) not accessible
1&gt;          could be the friend function at 'd:\blub\main.cpp(5)' : 'dot'  [may be found via argument-dependent lookup]
</code></pre>
<p>Sobald die Funktion außerhalb des struct definiert wird, klappt alles. Hat jemand eine Erklärung dafür? Ich vermute mal, dass es sich um einen Compilerbug handelt, denn imo sollte das perfekt standardkonformer Code sein...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2246075</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2246075</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Mon, 27 Aug 2012 20:57:04 GMT</pubDate></item><item><title><![CDATA[Reply to friend function in decltype in trailing return type on Mon, 27 Aug 2012 21:22:44 GMT]]></title><description><![CDATA[<p>dot schrieb:</p>
<blockquote>
<p>Ich vermute mal, dass es sich um einen Compilerbug handelt, denn imo sollte das perfekt standardkonformer Code sein...</p>
</blockquote>
<p>Mit clang und gcc kompiliert es anstandslos.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2246088</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2246088</guid><dc:creator><![CDATA[comiler-bot]]></dc:creator><pubDate>Mon, 27 Aug 2012 21:22:44 GMT</pubDate></item><item><title><![CDATA[Reply to friend function in decltype in trailing return type on Mon, 27 Aug 2012 22:00:27 GMT]]></title><description><![CDATA[<p>comiler-bot schrieb:</p>
<blockquote>
<p>dot schrieb:</p>
<blockquote>
<p>Ich vermute mal, dass es sich um einen Compilerbug handelt, denn imo sollte das perfekt standardkonformer Code sein...</p>
</blockquote>
<p>Mit clang und gcc kompiliert es anstandslos.</p>
</blockquote>
<p>Vielen Dank fürs ausprobieren, werd dann mal einen Bugreport schreiben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2246096</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2246096</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Mon, 27 Aug 2012 22:00:27 GMT</pubDate></item></channel></rss>