<?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[Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen?]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich schreibe gerade meine erstes größeres Projekt (meine Bachelorarbeit) in c++ und sehe daher manche Codeabschnitte, die ich geschrieben habe, nur alle paar Tage. In manchen Funktionen muss ich mehrere Parameter des gleichen Typs übergeben, so dass ich dann einen Aufruf wie draw_axis(true, true, false); sehe und nicht mehr auf den ersten Blick sehe, was die einzelnen Parameter bedeuten.</p>
<p>Zwar könnte ich direkt lokale Variablen mit passenden Namen anlegen und die dann übergeben, nur sieht das nicht gerade toll aus. Gibt es eine Möglichkeit, die Parameternamen auch im Aufruf zu benutzen? Also einen Aufruf wie draw_axis(foo=true, bar=false, false); zu machen?<br />
Ich dachte, ich hätte so was mal bei Delphi gesehen, bei C++ bin ich mir unsicher...</p>
<p>Nikolas</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/243145/funktion-f-bool-p1-bool-p2-als-f-p1-true-p2-false-aufrufen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 20 Sep 2026 03:01:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/243145.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 13 Jun 2009 06:00:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 06:00:11 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich schreibe gerade meine erstes größeres Projekt (meine Bachelorarbeit) in c++ und sehe daher manche Codeabschnitte, die ich geschrieben habe, nur alle paar Tage. In manchen Funktionen muss ich mehrere Parameter des gleichen Typs übergeben, so dass ich dann einen Aufruf wie draw_axis(true, true, false); sehe und nicht mehr auf den ersten Blick sehe, was die einzelnen Parameter bedeuten.</p>
<p>Zwar könnte ich direkt lokale Variablen mit passenden Namen anlegen und die dann übergeben, nur sieht das nicht gerade toll aus. Gibt es eine Möglichkeit, die Parameternamen auch im Aufruf zu benutzen? Also einen Aufruf wie draw_axis(foo=true, bar=false, false); zu machen?<br />
Ich dachte, ich hätte so was mal bei Delphi gesehen, bei C++ bin ich mir unsicher...</p>
<p>Nikolas</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1725870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1725870</guid><dc:creator><![CDATA[Nikolas]]></dc:creator><pubDate>Sat, 13 Jun 2009 06:00:11 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 06:47:12 GMT]]></title><description><![CDATA[<p><a href="http://www.boost.org/doc/libs/1_39_0/libs/parameter/doc/html/index.html" rel="nofollow">http://www.boost.org/doc/libs/1_39_0/libs/parameter/doc/html/index.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1725874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1725874</guid><dc:creator><![CDATA[life]]></dc:creator><pubDate>Sat, 13 Jun 2009 06:47:12 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 07:00:25 GMT]]></title><description><![CDATA[<p>enums?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1725877</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1725877</guid><dc:creator><![CDATA[mumumms]]></dc:creator><pubDate>Sat, 13 Jun 2009 07:00:25 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 10:46:34 GMT]]></title><description><![CDATA[<p>mumumms schrieb:</p>
<blockquote>
<p>enums?</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1725922</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1725922</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Sat, 13 Jun 2009 10:46:34 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 10:59:49 GMT]]></title><description><![CDATA[<p>Badestrand schrieb:</p>
<blockquote>
<p>mumumms schrieb:</p>
<blockquote>
<p>enums?</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1725925</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1725925</guid><dc:creator><![CDATA[acker]]></dc:creator><pubDate>Sat, 13 Jun 2009 10:59:49 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 11:08:39 GMT]]></title><description><![CDATA[<p>Eine anständige IDE sollte da reichen. Nur um das zu kompensieren würde ich nicht boost benutzen.. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1725929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1725929</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 13 Jun 2009 11:08:39 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 13:38:12 GMT]]></title><description><![CDATA[<p>Auch mit anständiger IDE würde ich Enums nehmen oder sogar Typen. Ziemlich gutes Beispiel, wo man auch Typen einsetzen kann:</p>
<pre><code class="language-cpp">Date date(Month(10), Day(1), Year(2004));
// Statt:
Date date(10, 1, 2004);
</code></pre>
<p>Für <code>bool</code> Argumente reicht aber meistens ein Enum.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1725984</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1725984</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sat, 13 Jun 2009 13:38:12 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 15:00:25 GMT]]></title><description><![CDATA[<p>Oder doch lieber die Boost-Keule rausholen:</p>
<pre><code class="language-cpp">Date date(month = 10, day = 1, year = 2004); //ok
Date date(day = 1, month = 10, year = 2004); //auch ok
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1726020</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1726020</guid><dc:creator><![CDATA[life]]></dc:creator><pubDate>Sat, 13 Jun 2009 15:00:25 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 15:12:07 GMT]]></title><description><![CDATA[<p>life schrieb:</p>
<blockquote>
<p>Oder doch lieber die Boost-Keule rausholen:</p>
</blockquote>
<p>Die Verwendung mag zwar schön und flexibel aussehen mit Boost, aber die Realisierung finde ich äusserst hässlich. Solchen Code, der dabei entsteht, kann man nur äusserst schlecht lesen. Ich mein schau dir nur mal das Beispiel an:</p>
<pre><code class="language-cpp">#include &lt;boost/parameter/name.hpp&gt;

namespace graphs
{
  BOOST_PARAMETER_NAME(graph)    // Note: no semicolon
  BOOST_PARAMETER_NAME(visitor)
  BOOST_PARAMETER_NAME(root_vertex)
  BOOST_PARAMETER_NAME(index_map)
  BOOST_PARAMETER_NAME(color_map)

  BOOST_PARAMETER_FUNCTION(
      (void),                // 1. parenthesized return type
      depth_first_search,    // 2. name of the function template

      tag,                   // 3. namespace of tag types

      (required (graph, *) ) // 4. one required parameter, and

      (optional              //    four optional parameters, with defaults
        (visitor,           *, boost::dfs_visitor&lt;&gt;())
        (root_vertex,       *, *vertices(graph).first)
        (index_map,         *, get(boost::vertex_index,graph))
        (in_out(color_map), *,
          default_color_map(num_vertices(graph), index_map) )
      )
  )
  {
      // ... body of function goes here...
      // use graph, visitor, index_map, and color_map
  }
}
</code></pre>
<p>*würgt und kotzt* <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="😉"
    /></p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1726025</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1726025</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sat, 13 Jun 2009 15:12:07 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 15:59:05 GMT]]></title><description><![CDATA[<p>Ich möchte nicht wissen, wie das ganze aussieht, wenn das durch den Präprozessor durch ist. -.-</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1726042</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1726042</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 13 Jun 2009 15:59:05 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 16:04:45 GMT]]></title><description><![CDATA[<p>visual studio 2008 zeigt bei mir, wenn ich mit dem mauszeiger über einen Funktionsaufruf fahre immer die Deklarations dieser Funktion an</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1726045</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1726045</guid><dc:creator><![CDATA[harg]]></dc:creator><pubDate>Sat, 13 Jun 2009 16:04:45 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 16:50:58 GMT]]></title><description><![CDATA[<p>Hab mal ausprobiert, wie hässlich so eine Date Funktion wirklich ist:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;boost/parameter/preprocessor.hpp&gt;
#include &lt;boost/parameter/name.hpp&gt; 

BOOST_PARAMETER_NAME(day)
BOOST_PARAMETER_NAME(month)
BOOST_PARAMETER_NAME(year)

BOOST_PARAMETER_FUNCTION((void), print_date, tag, 
						 (required (day,(int))(month,(int))(year,(int))))
{
	std::cout &lt;&lt; day &lt;&lt; &quot;.&quot; &lt;&lt; month &lt;&lt; &quot;.&quot; &lt;&lt; year &lt;&lt; std::endl;
}

int main() {
	print_date(_day=13, _month=6, _year=2009);
	print_date(_month=6, _day=13, _year=2009);
}
</code></pre>
<p>Ist schon etwas gewöhnungsbedürftig.. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1726055</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1726055</guid><dc:creator><![CDATA[life]]></dc:creator><pubDate>Sat, 13 Jun 2009 16:50:58 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 17:57:17 GMT]]></title><description><![CDATA[<p>Manchmal finde ich Boost schon etwas übertrieben. Wird hier für jede Parameterkombination eine eigene Funktion erzeugt?</p>
<p>Nur weil es einem zu unflexibel ist, sich an eine Parameterreihenfolge zu halten? Das Problem habe ich oft, dann setze ich die gewünschten Parameter halt per Setter. Viel flexibler, kein unnötiger Code-Bloat oder intransparente Präprozessormagie. Dafür mehrere Zeilen, das ist natürlich schon ein Problem.</p>
<p><em>Edit: Das ist meine persönliche Meinung.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1726083</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1726083</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sat, 13 Jun 2009 17:57:17 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Sat, 13 Jun 2009 18:31:21 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>Nur weil es einem zu unflexibel ist, sich an eine Parameterreihenfolge zu halten? Das Problem habe ich oft, dann setze ich die gewünschten Parameter halt per Setter. Viel flexibler, kein unnötiger Code-Bloat oder intransparente Präprozessormagie. Dafür mehrere Zeilen, das ist natürlich schon ein Problem.</p>
<p><em>Edit: Das ist meine persönliche Meinung.</em></p>
</blockquote>
<p>Da bin ich grundsätzlich auch deiner Meinung, allerdings denke ich nicht, dass das wirklich gedacht war produktiv zu nutzen, sondern eher sich mal einer dran gesetzt hat und geschaut hat, ob so etwas möglich ist. (wahrscheinlich nicht zu letzt um den ewigen &quot;C++ ist allen dynamischen Sprachen unterlegen&quot; Diskussionen einhalt zu geben). Ich finds nett zu sehen, dass es geht und in etwa wie, aber mir würde nie im Traum in Sinn kommen das ernsthaft zu nutzen.. <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 />
Das coole daran ist ja, dass zur Laufzeit keinerlei Nachteile dadurch enstehen, dass man eine dynamischere Syntax hat. Und das alleine finde ich schon bemerkenswert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1726103</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1726103</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 13 Jun 2009 18:31:21 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion f(bool p1, bool p2) als f(p1=true, p2=false); aufrufen? on Wed, 17 Jun 2009 15:04:33 GMT]]></title><description><![CDATA[<p>Vielen Dank für die vielen Ideen. Ich hatte gehofft, dass es da schon etwas gibt, etwas neues dafür einbauen, dass als neue Fehlerquelle dienen kann, will ich lieber nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1728293</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1728293</guid><dc:creator><![CDATA[Nikolas]]></dc:creator><pubDate>Wed, 17 Jun 2009 15:04:33 GMT</pubDate></item></channel></rss>