<?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[% BETWEEN % AND % als infix makro]]></title><description><![CDATA[<p>Hey ...</p>
<p>wir alle kennen sowas:</p>
<pre><code>int x = 1;
int y = 2;
int z = 3;

if (y &gt; x &amp;&amp; y &lt; z)
{
   // ...
}
</code></pre>
<p>Habe heute zufäligg davon gelesen, dass ich mit #define infix-Expressiones bauen kann (<a href="http://stackoverflow.com/questions/15632217/defining-new-infix-operators" rel="nofollow">http://stackoverflow.com/questions/15632217/defining-new-infix-operators</a>).</p>
<p>Jetzt würde ich mir gern eine Expression schreiben, die das hier unterstützt:</p>
<pre><code>int x = 1;
int y = 2;
int z = 3;

if (y between x and z)
{
   // ...
}
</code></pre>
<p>Irgendwelche Ideen?</p>
<p>mfg, guni</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/326438/between-and-als-infix-makro</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 23:48:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/326438.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Jun 2014 09:43:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to % BETWEEN % AND % als infix makro on Wed, 18 Jun 2014 09:43:42 GMT]]></title><description><![CDATA[<p>Hey ...</p>
<p>wir alle kennen sowas:</p>
<pre><code>int x = 1;
int y = 2;
int z = 3;

if (y &gt; x &amp;&amp; y &lt; z)
{
   // ...
}
</code></pre>
<p>Habe heute zufäligg davon gelesen, dass ich mit #define infix-Expressiones bauen kann (<a href="http://stackoverflow.com/questions/15632217/defining-new-infix-operators" rel="nofollow">http://stackoverflow.com/questions/15632217/defining-new-infix-operators</a>).</p>
<p>Jetzt würde ich mir gern eine Expression schreiben, die das hier unterstützt:</p>
<pre><code>int x = 1;
int y = 2;
int z = 3;

if (y between x and z)
{
   // ...
}
</code></pre>
<p>Irgendwelche Ideen?</p>
<p>mfg, guni</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2404368</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2404368</guid><dc:creator><![CDATA[guni]]></dc:creator><pubDate>Wed, 18 Jun 2014 09:43:42 GMT</pubDate></item><item><title><![CDATA[Reply to % BETWEEN % AND % als infix makro on Wed, 18 Jun 2014 10:00:05 GMT]]></title><description><![CDATA[<p><a href="http://ideone.com/CmqeiP" rel="nofollow">http://ideone.com/CmqeiP</a><br />
Muss Capslock sein, da and ein Schluesselwort ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2404378</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2404378</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Wed, 18 Jun 2014 10:00:05 GMT</pubDate></item><item><title><![CDATA[Reply to % BETWEEN % AND % als infix makro on Wed, 18 Jun 2014 10:01:34 GMT]]></title><description><![CDATA[<p>Als Spielerei und Grenz-Erkundung von C++ ist das ja ganz nett, aber ich hoffe schwer, ihr habt nicht vor, solche Konstrukte produktiv einzusetzen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2404379</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2404379</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Wed, 18 Jun 2014 10:01:34 GMT</pubDate></item><item><title><![CDATA[Reply to % BETWEEN % AND % als infix makro on Wed, 18 Jun 2014 10:21:25 GMT]]></title><description><![CDATA[<p>Wenn man unbedingt so etwas will, sollte man dies wenigstens nicht als Makro machen. Eine Möglichkeit ist das Verwenden eines Hilfskonstruktes (würde ich an dieser Stelle zwar nicht verwenden, hatte aber schon vergleichbare Stellen gehabt, wo der Nutzen der Lesbarkeit höher als der Aufwand war).</p>
<p>Ungeprüft</p>
<pre><code>class Integer
{
    public:
        Integer(int value)
        : value(value)
        {}

        bool between(int from, int to)
        {
            return value&gt;=from &amp;&amp; value&lt;=to;
        }

    private:
        int value;
}

int main()
{
    int x = 1;
    int y = 2;
    int z = 3;

    if(Integer(y).between(x, z))
    {
       // ...
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2404389</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2404389</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Wed, 18 Jun 2014 10:21:25 GMT</pubDate></item><item><title><![CDATA[Reply to % BETWEEN % AND % als infix makro on Wed, 18 Jun 2014 10:40:55 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>Als Spielerei und Grenz-Erkundung von C++ ist das ja ganz nett, aber ich hoffe schwer, ihr habt nicht vor, solche Konstrukte produktiv einzusetzen...</p>
</blockquote>
<p>Ja. Es soll eine reine Spielerei und Grenz-Erkundung sein; das triffts genau <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";-)"
      alt="😉"
    /><br />
Aber die Antwort wirft trotzdem eine Frage auf: was würde gegen produktiven Einsatz sprechen? (Wenn man mal davon absieht, dass die tyüesaftey flöten geht und das debugging übel wird)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2404391</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2404391</guid><dc:creator><![CDATA[guni]]></dc:creator><pubDate>Wed, 18 Jun 2014 10:40:55 GMT</pubDate></item><item><title><![CDATA[Reply to % BETWEEN % AND % als infix makro on Wed, 18 Jun 2014 10:46:25 GMT]]></title><description><![CDATA[<p>guni schrieb:</p>
<blockquote>
<p>was würde gegen produktiven Einsatz sprechen? (Wenn man mal davon absieht, dass die tyüesaftey flöten geht und das debugging übel wird)</p>
</blockquote>
<p>Alleine die beiden Nachteile wären für mich schon ein sehr guter Grund dafür. Davon abgesehen das Makros noch unschöne Nebeneffekte haben können. Wenn ich eine Between Funktionalität haben will, nehme ich eine etwas unschönere Syntax, dafür ohne eben diese Nachteile in Kauf (Wobei ich in dem Fall nicht zu der von mir angegebenen Klasse, sondern eher einer freien Funktion mit 3 Argumenten tendieren würde).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2404395</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2404395</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Wed, 18 Jun 2014 10:46:25 GMT</pubDate></item><item><title><![CDATA[Reply to % BETWEEN % AND % als infix makro on Wed, 18 Jun 2014 11:00:13 GMT]]></title><description><![CDATA[<p>Vorteile:</p>
<ul>
<li>Minimal schönere Syntax, und das nur subjektiv</li>
</ul>
<p>Nachteile:</p>
<ul>
<li>Braucht massiv mehr Code und Zeit für die Implementierung</li>
<li>Schwieriger zu debuggen</li>
<li>Schwieriger zu warten</li>
<li>Weniger typsicher</li>
<li>Niemand versteht den Code</li>
<li>Potentiell höhere Kompilierzeit und Möglichkeit, dass der Compiler nicht alles wegoptimiert</li>
<li>Unschöne Makro-Effekte, wenn man nicht wahnsinnig aufpasst</li>
</ul>
<p>Die Frage des produktiven Einsatzes dürfte damit geklärt sein <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>
]]></description><link>https://www.c-plusplus.net/forum/post/2404399</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2404399</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Wed, 18 Jun 2014 11:00:13 GMT</pubDate></item><item><title><![CDATA[Reply to % BETWEEN % AND % als infix makro on Wed, 18 Jun 2014 15:42:17 GMT]]></title><description><![CDATA[<p>Wo ist hier das Problem bezüglich Typsicherheit?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2404459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2404459</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Wed, 18 Jun 2014 15:42:17 GMT</pubDate></item><item><title><![CDATA[Reply to % BETWEEN % AND % als infix makro on Wed, 18 Jun 2014 23:10:00 GMT]]></title><description><![CDATA[<p>Na ja. Bei einem makro erkennt der compiler meines wissens nach nicht, ob die verwendeten datentypen stimmen =&gt; fehler zur laufzeit. Wie auch immer: meine frage war ursprünglich eher ob sowas machbar is; nicht primär ob es sinnvoll is ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2404533</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2404533</guid><dc:creator><![CDATA[guni]]></dc:creator><pubDate>Wed, 18 Jun 2014 23:10:00 GMT</pubDate></item><item><title><![CDATA[Reply to % BETWEEN % AND % als infix makro on Wed, 18 Jun 2014 23:32:00 GMT]]></title><description><![CDATA[<p>guni schrieb:</p>
<blockquote>
<p>Na ja. Bei einem makro erkennt der compiler meines wissens nach nicht, ob die verwendeten datentypen stimmen =&gt; fehler zur laufzeit. Wie auch immer: meine frage war ursprünglich eher ob sowas machbar is; nicht primär ob es sinnvoll is ...</p>
</blockquote>
<p>Der Prepro macht die Replacements und danach ist das ganz normaler C++ code als wären die makros nie da gewesen (für den Compiler). Da werden natürlich noch Warnungen (zum Beispiel: signed und unsigned gemischt) etc angezeigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2404534</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2404534</guid><dc:creator><![CDATA[5cript]]></dc:creator><pubDate>Wed, 18 Jun 2014 23:32:00 GMT</pubDate></item><item><title><![CDATA[Reply to % BETWEEN % AND % als infix makro on Fri, 20 Jun 2014 10:57:36 GMT]]></title><description><![CDATA[<p>Dann schreib ich i + 1 BETWEEN j &lt;&lt; 1 AND k &gt;&gt; 2 und versuch die Fehlermeldungen zu entziffern. Solcher Firlefanz macht richtig Spaß, sofern man ausreichend masochistisch veranlagt ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2404699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2404699</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Fri, 20 Jun 2014 10:57:36 GMT</pubDate></item></channel></rss>