<?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[Schreibweisen für Funktionen in Namespaces]]></title><description><![CDATA[<p>Hallo,</p>
<p>bisher habe ich die Namen meiner Namespaces meistens ausgeschrieben.<br />
Jetzt bin ich auf die ::function-Notation gestoßen und frage mich,<br />
ob es für bestimmte andere Fälle auch kürzere Schreibweisen gibt.</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;iostream&gt;

void bar(){
        std::cout &lt;&lt; &quot;-&quot; &lt;&lt; std::endl;
}

namespace foo{
        void bar(){
                std::cout &lt;&lt; &quot;foo&quot; &lt;&lt; std::endl;
        }

        namespace a{

                void bar(){
                        std::cout &lt;&lt; &quot;foo::a&quot; &lt;&lt; std::endl;
                }
        }

        namespace b{
                void bar(){
                        std::cout &lt;&lt; &quot;foo::b&quot; &lt;&lt; std::endl;
                }

                void foobar(){
                        bar();
                        ::bar();
                        foo::bar(); // &lt;- Hierfür ne andere Schreibweise
                        foo::a::bar(); // &lt;- Hierfür ne andere Schreibweise
                }

        }
}

int main(int argc, char** arg) {
        foo::b::foobar();
        return 0;
}
</code></pre>
<blockquote>
<h2>foo::b</h2>
<p>foo<br />
foo::a</p>
</blockquote>
<p>Gibt es für die gekennzeichneten Zeilen alternative Schreibweisen?<br />
Also irgendetwas für eine Namespace-Ebene hoch...</p>
<p>Gruß,<br />
Mark</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/284107/schreibweisen-für-funktionen-in-namespaces</link><generator>RSS for Node</generator><lastBuildDate>Sat, 22 Aug 2026 07:37:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/284107.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Mar 2011 19:34:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Schreibweisen für Funktionen in Namespaces on Fri, 25 Mar 2011 19:34:04 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>bisher habe ich die Namen meiner Namespaces meistens ausgeschrieben.<br />
Jetzt bin ich auf die ::function-Notation gestoßen und frage mich,<br />
ob es für bestimmte andere Fälle auch kürzere Schreibweisen gibt.</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;iostream&gt;

void bar(){
        std::cout &lt;&lt; &quot;-&quot; &lt;&lt; std::endl;
}

namespace foo{
        void bar(){
                std::cout &lt;&lt; &quot;foo&quot; &lt;&lt; std::endl;
        }

        namespace a{

                void bar(){
                        std::cout &lt;&lt; &quot;foo::a&quot; &lt;&lt; std::endl;
                }
        }

        namespace b{
                void bar(){
                        std::cout &lt;&lt; &quot;foo::b&quot; &lt;&lt; std::endl;
                }

                void foobar(){
                        bar();
                        ::bar();
                        foo::bar(); // &lt;- Hierfür ne andere Schreibweise
                        foo::a::bar(); // &lt;- Hierfür ne andere Schreibweise
                }

        }
}

int main(int argc, char** arg) {
        foo::b::foobar();
        return 0;
}
</code></pre>
<blockquote>
<h2>foo::b</h2>
<p>foo<br />
foo::a</p>
</blockquote>
<p>Gibt es für die gekennzeichneten Zeilen alternative Schreibweisen?<br />
Also irgendetwas für eine Namespace-Ebene hoch...</p>
<p>Gruß,<br />
Mark</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2040147</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2040147</guid><dc:creator><![CDATA[Mark81]]></dc:creator><pubDate>Fri, 25 Mar 2011 19:34:04 GMT</pubDate></item><item><title><![CDATA[Reply to Schreibweisen für Funktionen in Namespaces on Fri, 25 Mar 2011 20:21:35 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">namespace fa = foo::a;
</code></pre>
<p>Aber grundsätzlich halte ich Schachtelungen tiefer als zwei Ebenen in den meisten Fällen für fragwürdig. Die Gliederung wird dadurch nicht zwangsläufig besser. Bei einer Bibliothek würde ich persönlich darauf achten, dass die meisten Bezeichner im Top-Level-Namensraum sind, und vielleicht einzelne zusammengehörige Funktionalität oder der Scope von Enums in geschachtelten Namensräumen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2040162</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2040162</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 25 Mar 2011 20:21:35 GMT</pubDate></item><item><title><![CDATA[Reply to Schreibweisen für Funktionen in Namespaces on Fri, 25 Mar 2011 23:45:35 GMT]]></title><description><![CDATA[<p>boost::asio::ip::tcp::resolver::iterator <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>
]]></description><link>https://www.c-plusplus.net/forum/post/2040222</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2040222</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Fri, 25 Mar 2011 23:45:35 GMT</pubDate></item><item><title><![CDATA[Reply to Schreibweisen für Funktionen in Namespaces on Sat, 26 Mar 2011 00:42:10 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<pre><code class="language-cpp">namespace fa = foo::a;
</code></pre>
</blockquote>
<p>Guter Vorschlag!!!<br />
Hab ich noch nie verwendet, obwohl ich es schon häufiger gesehen habe.</p>
<p>Ich wollte auch maximal 3 Ebenen verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2040233</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2040233</guid><dc:creator><![CDATA[Mark81]]></dc:creator><pubDate>Sat, 26 Mar 2011 00:42:10 GMT</pubDate></item></channel></rss>