<?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[Call to is ambiguous nur für Clang]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe folgendes in meinem Header:</p>
<pre><code>/**
     * Returns true, if lhs is smaller than rhs by more than tolerance.
     */
    template&lt;typename Type&gt;
      typename utils::EnableIf&lt;(not IsVector&lt;Type&gt;::value),
      bool
    &gt;::Type smaller (
      Type lhs,
      Type rhs,
      Type tolerance = NUMERICAL_ZERO_DIFFERENCE);

    /**
     * Returns true, if lhs is equals or smaller than rhs by more than tolerance.
     */
    template&lt;typename Type&gt;
      typename utils::EnableIf&lt;(not IsVector&lt;Type&gt;::value),
      bool
    &gt;::Type smallerEquals (
      Type lhs,
      Type rhs,
      Type tolerance = NUMERICAL_ZERO_DIFFERENCE);
</code></pre>
<p>in dazugehöriger Definition:</p>
<pre><code>template&lt;typename Type&gt;
  inline
  typename utils::EnableIf&lt;(not IsVector&lt;Type&gt;::value),
  bool
&gt;::Type smaller (
  Type lhs,
  Type rhs,
  Type tolerance
) {
  return lhs - rhs &lt; -tolerance;
}

template&lt;typename Type&gt;
  inline
  typename utils::EnableIf&lt;not IsVector&lt;Type&gt;::value,
  bool
&gt;::Type smallerEquals (
  Type lhs,
  Type rhs,
  Type tolerance
) {
  return lhs - rhs &lt;= tolerance;
}
</code></pre>
<p>das ganze wird nun getestet:</p>
<pre><code>validate (smaller(a, b, eps));
  validate (smallerEquals(a, b, eps));
</code></pre>
<p>Der ganze Code kompiliert problemlos mit gcc 4.9.1. Wenn ich nun probiere es mit clang++ 3.4.2 zu kompilieren, meldet smallerEquals (und nur smallerEquals!) einen Fehler:</p>
<pre><code>clang++ -o build/debug/tarch/la/tests/ScalarTest.o -c -fPIC -g3 -O0 -DDebug -DAsserts -Isrc -Isrc -I/usr/include/openmpi -I/usr/include -I/usr/include/python2.7 -I/usr/include/python2.7/numpy src/tarch/la/tests/ScalarTest.cpp
src/tarch/la/tests/ScalarTest.cpp:53:13: error: call to 'smallerEquals' is ambiguous
  validate (smallerEquals(a, b, eps));
            ^~~~~~~~~~~~~
src/tarch/tests/TestMacros.h:45:37: note: expanded from macro 'validate'
#define validate(booleanExpr) if (!(booleanExpr)) { \
                                    ^
src/tarch/la/ScalarOperations.h:77:13: note: candidate function [with Type = double]
    &gt;::Type smallerEquals (
            ^
src/tarch/la/ScalarOperations.cpph:79:9: note: candidate function [with Type = double]
&gt;::Type smallerEquals (
        ^
1 error generated.
</code></pre>
<p>Mir ist vor allem vollständig unverständlich, weshalb smaller keinen Fehler produziert, smallerEquals jedoch schon. Und das wiederrum nur mit clang, nicht mit gcc. Eben habe ich nochmal im Verzeichniss gegrept, smaller / smallerEquals kommt nur an den obigen Stellen vor.</p>
<p>Ich habe auch schon mal versucht smaller und smallerEquals zu vertauschen (sowohl im Aufruf als auch in Definition/Deklaration), aber der Fehler bleibt bei smallerEquals.</p>
<p>Wer kann mir Tipps geben, wo da das Problem sein könnte? Sollten noch Infos fehlen, liefere ich gerne alles nach!</p>
<p>Vielen Dank und Grüße,<br />
Florian</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/327117/call-to-is-ambiguous-nur-für-clang</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Jul 2026 20:22:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/327117.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 Jul 2014 13:32:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Call to is ambiguous nur für Clang on Thu, 24 Jul 2014 13:32:40 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe folgendes in meinem Header:</p>
<pre><code>/**
     * Returns true, if lhs is smaller than rhs by more than tolerance.
     */
    template&lt;typename Type&gt;
      typename utils::EnableIf&lt;(not IsVector&lt;Type&gt;::value),
      bool
    &gt;::Type smaller (
      Type lhs,
      Type rhs,
      Type tolerance = NUMERICAL_ZERO_DIFFERENCE);

    /**
     * Returns true, if lhs is equals or smaller than rhs by more than tolerance.
     */
    template&lt;typename Type&gt;
      typename utils::EnableIf&lt;(not IsVector&lt;Type&gt;::value),
      bool
    &gt;::Type smallerEquals (
      Type lhs,
      Type rhs,
      Type tolerance = NUMERICAL_ZERO_DIFFERENCE);
</code></pre>
<p>in dazugehöriger Definition:</p>
<pre><code>template&lt;typename Type&gt;
  inline
  typename utils::EnableIf&lt;(not IsVector&lt;Type&gt;::value),
  bool
&gt;::Type smaller (
  Type lhs,
  Type rhs,
  Type tolerance
) {
  return lhs - rhs &lt; -tolerance;
}

template&lt;typename Type&gt;
  inline
  typename utils::EnableIf&lt;not IsVector&lt;Type&gt;::value,
  bool
&gt;::Type smallerEquals (
  Type lhs,
  Type rhs,
  Type tolerance
) {
  return lhs - rhs &lt;= tolerance;
}
</code></pre>
<p>das ganze wird nun getestet:</p>
<pre><code>validate (smaller(a, b, eps));
  validate (smallerEquals(a, b, eps));
</code></pre>
<p>Der ganze Code kompiliert problemlos mit gcc 4.9.1. Wenn ich nun probiere es mit clang++ 3.4.2 zu kompilieren, meldet smallerEquals (und nur smallerEquals!) einen Fehler:</p>
<pre><code>clang++ -o build/debug/tarch/la/tests/ScalarTest.o -c -fPIC -g3 -O0 -DDebug -DAsserts -Isrc -Isrc -I/usr/include/openmpi -I/usr/include -I/usr/include/python2.7 -I/usr/include/python2.7/numpy src/tarch/la/tests/ScalarTest.cpp
src/tarch/la/tests/ScalarTest.cpp:53:13: error: call to 'smallerEquals' is ambiguous
  validate (smallerEquals(a, b, eps));
            ^~~~~~~~~~~~~
src/tarch/tests/TestMacros.h:45:37: note: expanded from macro 'validate'
#define validate(booleanExpr) if (!(booleanExpr)) { \
                                    ^
src/tarch/la/ScalarOperations.h:77:13: note: candidate function [with Type = double]
    &gt;::Type smallerEquals (
            ^
src/tarch/la/ScalarOperations.cpph:79:9: note: candidate function [with Type = double]
&gt;::Type smallerEquals (
        ^
1 error generated.
</code></pre>
<p>Mir ist vor allem vollständig unverständlich, weshalb smaller keinen Fehler produziert, smallerEquals jedoch schon. Und das wiederrum nur mit clang, nicht mit gcc. Eben habe ich nochmal im Verzeichniss gegrept, smaller / smallerEquals kommt nur an den obigen Stellen vor.</p>
<p>Ich habe auch schon mal versucht smaller und smallerEquals zu vertauschen (sowohl im Aufruf als auch in Definition/Deklaration), aber der Fehler bleibt bei smallerEquals.</p>
<p>Wer kann mir Tipps geben, wo da das Problem sein könnte? Sollten noch Infos fehlen, liefere ich gerne alles nach!</p>
<p>Vielen Dank und Grüße,<br />
Florian</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2410289</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2410289</guid><dc:creator><![CDATA[Horus107]]></dc:creator><pubDate>Thu, 24 Jul 2014 13:32:40 GMT</pubDate></item><item><title><![CDATA[Reply to Call to is ambiguous nur für Clang on Thu, 24 Jul 2014 14:17:56 GMT]]></title><description><![CDATA[<p>Clang nimmt wohl fälschlicherweise an, dass du zwei verschiedene Funktionstemplates deklarierst; dabei wird es sich um einen Bug handeln.</p>
<p>P.S.:<br />
Warum verwendest du nicht <code>std::enable_if</code> ? Kompilierst du etwa für C++03?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2410296</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2410296</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Thu, 24 Jul 2014 14:17:56 GMT</pubDate></item><item><title><![CDATA[Reply to Call to is ambiguous nur für Clang on Thu, 24 Jul 2014 14:29:52 GMT]]></title><description><![CDATA[<p>Clang beißt sich an den Klammern um den Ausdruck im Template-Argument an <code>enable_if</code> fest <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<pre><code>#include &lt;type_traits&gt;

auto const NUMERICAL_ZERO_DIFFERENCE = 351;

template&lt;typename Type&gt;
typename std::enable_if&lt;( not std::is_integral&lt;Type&gt;::value ), bool&gt;::type /// Entferne hier die Klammern, dann kompiliert es
///                     ^                                   ^

smallerEquals ( Type lhs,
                Type rhs,
                Type tolerance = NUMERICAL_ZERO_DIFFERENCE );

template&lt;typename Type&gt;
inline
typename std::enable_if&lt;not std::is_integral&lt;Type&gt;::value, bool&gt;::type
smallerEquals( Type lhs,
               Type rhs,
               Type tolerance )
{
	return lhs - rhs &lt;= tolerance;
}

int main()
{
	float a{}, b{}, eps{};
	smallerEquals( a, b, eps );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2410299</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2410299</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Thu, 24 Jul 2014 14:29:52 GMT</pubDate></item><item><title><![CDATA[Reply to Call to is ambiguous nur für Clang on Fri, 25 Jul 2014 07:59:25 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Danke für den Code und den Tipp mit den Klammern. Probiere es morgen dann mal aus.</p>
<p>Ich kompiliere nicht nur für C++03, sondern sogar für C++98, also das was GNU und Clang ohne Optionen als Standard benutzen. Ich hoffe, dass das Projekt irgendwann auf C++11 umgestellt werden kann. Leider kommt es auch auf sehr großen HPC Systemen zum Einsatz und da sind die Compiler häufig etwas angestaubt.</p>
<p>Viele Grüße!</p>
<p>EDIT: Vielen Dank nochmal, jetzt läuft es und kompiliert mit clang.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2410312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2410312</guid><dc:creator><![CDATA[Horus107]]></dc:creator><pubDate>Fri, 25 Jul 2014 07:59:25 GMT</pubDate></item><item><title><![CDATA[Reply to Call to is ambiguous nur für Clang on Thu, 24 Jul 2014 16:05:57 GMT]]></title><description><![CDATA[<p>Arcoth schrieb:</p>
<blockquote>
<p>Clang beißt sich an den Klammern um den Ausdruck im Template-Argument an <code>enable_if</code> fest <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
</blockquote>
<p>und hat damit recht. Und gcc hat auch recht, das Programm ist ill-formed, muss aber nicht diagnostiziert werden (14.5.6.1/6). U.a. Die Templateargumentliste zwischen verschiedenen Deklarationen des gleichen Templates muss Token für Token identisch sein, ausser dass andere Templateparameternamen verwendet werden dürfen, und diese in der Argumentlist entsprechend substituiert werden. Klammern schliesst das leider nicht ein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2410315</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2410315</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 24 Jul 2014 16:05:57 GMT</pubDate></item></channel></rss>