<?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[SFINAE does not apply :(]]></title><description><![CDATA[<p>Folgendes ist (wie zu erwarten war) Unsinn: (EDIT: Wie sich weiter unten herausstellt: ist doch kein Unsinn)</p>
<pre><code>template &lt;typename T, typename Stub = mplex::char_&lt;0&gt; &gt;
struct takes_one {
    typedef char yes[1];
    typedef char no[2];

    template &lt;typename C&gt;
    static yes&amp; test(typename C::template apply &lt;Stub&gt;*); 

    template &lt;typename&gt;
    static no&amp; test(...);

    static const bool value = sizeof(test&lt;T&gt;(nullptr)) == sizeof(yes);
};

int main () {
    std::cout &lt;&lt; takes_one &lt;is_equal&gt;::value;
}
</code></pre>
<p>Ist klar was ich versuche zu erreichen? (rausfinden wie viele Parameter apply akzeptiert ohne das hinterlegen zu müssen in is_equal).<br />
Ich habe die Vermutung dass das unmöglich ist, aber aus Hoffnung frage ich hier trotzdem.</p>
<p>EDIT: erweiterbar auf unendliche viele Parameter wäre von da aus ja easy (mit variadics ohne limit)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/333405/sfinae-does-not-apply</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 05:22:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/333405.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 02 Jul 2015 21:13:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to SFINAE does not apply :( on Fri, 03 Jul 2015 19:18:43 GMT]]></title><description><![CDATA[<p>Folgendes ist (wie zu erwarten war) Unsinn: (EDIT: Wie sich weiter unten herausstellt: ist doch kein Unsinn)</p>
<pre><code>template &lt;typename T, typename Stub = mplex::char_&lt;0&gt; &gt;
struct takes_one {
    typedef char yes[1];
    typedef char no[2];

    template &lt;typename C&gt;
    static yes&amp; test(typename C::template apply &lt;Stub&gt;*); 

    template &lt;typename&gt;
    static no&amp; test(...);

    static const bool value = sizeof(test&lt;T&gt;(nullptr)) == sizeof(yes);
};

int main () {
    std::cout &lt;&lt; takes_one &lt;is_equal&gt;::value;
}
</code></pre>
<p>Ist klar was ich versuche zu erreichen? (rausfinden wie viele Parameter apply akzeptiert ohne das hinterlegen zu müssen in is_equal).<br />
Ich habe die Vermutung dass das unmöglich ist, aber aus Hoffnung frage ich hier trotzdem.</p>
<p>EDIT: erweiterbar auf unendliche viele Parameter wäre von da aus ja easy (mit variadics ohne limit)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2458576</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2458576</guid><dc:creator><![CDATA[5cript]]></dc:creator><pubDate>Fri, 03 Jul 2015 19:18:43 GMT</pubDate></item><item><title><![CDATA[Reply to SFINAE does not apply :( on Fri, 03 Jul 2015 11:52:15 GMT]]></title><description><![CDATA[<p>hmm, die Frage ist für mich nicht so ganz einfach zu verstehen.<br />
Aber ich denke, apply ist ein Member Functiontemplate von is_equal?</p>
<p>d.h. irgendwie so?:</p>
<pre><code>#include &lt;iostream&gt;

struct is_equal
{
    template &lt;typename T&gt;
    void apply(T)
    {}
};

struct is_equal2
{
    template &lt;typename T&gt;
    void apply(T, T)
    {}
};

template &lt;typename C, typename R, typename... P&gt;
constexpr unsigned cnt(R (C::*p)(P...))
{
    return sizeof...(P);
}

template &lt;typename T, typename Stub = char* &gt;
struct takes_one 
{
    static const bool value = cnt(&amp; T::template apply&lt;Stub&gt;) == 1;
};

int main () 
{
    std::cout &lt;&lt; takes_one&lt;is_equal&gt;::value &lt;&lt; &quot;\n&quot;;
    std::cout &lt;&lt; takes_one&lt;is_equal2&gt;::value &lt;&lt; &quot;\n&quot;;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2458609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2458609</guid><dc:creator><![CDATA[__cu]]></dc:creator><pubDate>Fri, 03 Jul 2015 11:52:15 GMT</pubDate></item><item><title><![CDATA[Reply to SFINAE does not apply :( on Fri, 03 Jul 2015 13:00:57 GMT]]></title><description><![CDATA[<p>Oh ja ups. So einfach ist es leider nicht.</p>
<p>Beispiel:</p>
<pre><code>struct is_equal {
    constexpr static const int arity = 2; // &lt;- will ich mir sparen
    template &lt;typename T, typename U&gt;
    struct apply {
       using type = typename std::is_same &lt;T, U&gt;::type;
    };
};

struct is_space {
    constexpr static const int arity = 1; // &lt;- will ich mir sparen
    template &lt;typename CharT&gt;
    struct apply {
        using type = bool_ &lt;CharT::value == ' ' || CharT::value == '\n'; //...more
    };
};
</code></pre>
<p>ideal application</p>
<pre><code>takes_one&lt;is_space&gt;::value // true
takes_one&lt;is_equal&gt;::value // false
takes_two&lt;is_equal&gt;::value // true
takes_two&lt;is_space&gt;::value // false
</code></pre>
<p>further expansion of principle</p>
<pre><code>takes&lt;2, is_equal&gt;::value // true
</code></pre>
<p>Aber wenn das unmöglich ist mache ich es vermutlich so:</p>
<pre><code>template &lt;unsigned Arity&gt;
struct functor {
    constexpr static const unsigned arity = Arity;
    // more stuff
};

struct is_equal : functor &lt;2&gt; {
    //...
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2458615</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2458615</guid><dc:creator><![CDATA[5cript]]></dc:creator><pubDate>Fri, 03 Jul 2015 13:00:57 GMT</pubDate></item><item><title><![CDATA[Reply to SFINAE does not apply :( on Fri, 03 Jul 2015 18:40:11 GMT]]></title><description><![CDATA[<p>Dann verstehe ich allerdings nicht mehr, warum Deine Lösung ganz oben &quot;Unsinn&quot; sein soll <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":-)"
      alt="🙂"
    /></p>
<p>Wenn ich die ausprobiere, dann funktioniert eigentlich alles.<br />
siehe <a href="http://coliru.stacked-crooked.com/a/074d432531546335" rel="nofollow">http://coliru.stacked-crooked.com/a/074d432531546335</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2458641</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2458641</guid><dc:creator><![CDATA[__cu]]></dc:creator><pubDate>Fri, 03 Jul 2015 18:40:11 GMT</pubDate></item><item><title><![CDATA[Reply to SFINAE does not apply :( on Fri, 03 Jul 2015 21:09:45 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":O"
      alt="😮"
    /></p>
<p>g++ 4.9.2: error does not take 1 argument<br />
g++ 5.1.0: compiles<br />
clang 3.6.0: compiles</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /></p>
<p>Muss wohl noch auf mingw-w64 warten und bis dahin clang verwenden (ich will g++ und clang unterstützen (aber immer nur die neuste Version))</p>
<p>EDIT: jupp, sieht jetzt so aus:</p>
<pre><code>std::cout &lt;&lt; has_arity_v &lt;is_equal, 1&gt;::value &lt;&lt; &quot;\n&quot;; // 0
std::cout &lt;&lt; has_arity_v &lt;is_equal, 2&gt;::value &lt;&lt; &quot;\n&quot;; // 1
std::cout &lt;&lt; has_arity_v &lt;is_space, 1&gt;::value &lt;&lt; &quot;\n&quot;; // 1
std::cout &lt;&lt; has_arity_v &lt;is_space, 2&gt;::value &lt;&lt; &quot;\n&quot;; // 0
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2458644</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2458644</guid><dc:creator><![CDATA[5cript]]></dc:creator><pubDate>Fri, 03 Jul 2015 21:09:45 GMT</pubDate></item></channel></rss>