<?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[std::tr1 und std:: namespace supporten, aber wie am einfachsten?]]></title><description><![CDATA[<p>Hi ich möchte gerne std::tr1 und std:: namespace supporten</p>
<p>z.B. möchste ich std::tr1::is_function&lt;T&gt; benutzen wenn es das gibt<br />
und bei neueren compilern natürlich nur std::is_function&lt;T&gt;</p>
<p>Damit ich jetzt nicht überall in meinem code #ifdef HAS_TR1#elif oder so ähnlich schreibe, will ich std::tr1 in meinen namespace einbetten aber zentral.</p>
<p>so das ich dann nur noch in meinem code überall schreiben kann:</p>
<pre><code class="language-cpp">MyNS::is_function&lt;T&gt;
</code></pre>
<p>Wie kann ich das am Besten machen, wie macht ihr das?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/307238/std-tr1-und-std-namespace-supporten-aber-wie-am-einfachsten</link><generator>RSS for Node</generator><lastBuildDate>Fri, 07 Aug 2026 18:05:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/307238.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Aug 2012 20:40:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Mon, 20 Aug 2012 20:40:12 GMT]]></title><description><![CDATA[<p>Hi ich möchte gerne std::tr1 und std:: namespace supporten</p>
<p>z.B. möchste ich std::tr1::is_function&lt;T&gt; benutzen wenn es das gibt<br />
und bei neueren compilern natürlich nur std::is_function&lt;T&gt;</p>
<p>Damit ich jetzt nicht überall in meinem code #ifdef HAS_TR1#elif oder so ähnlich schreibe, will ich std::tr1 in meinen namespace einbetten aber zentral.</p>
<p>so das ich dann nur noch in meinem code überall schreiben kann:</p>
<pre><code class="language-cpp">MyNS::is_function&lt;T&gt;
</code></pre>
<p>Wie kann ich das am Besten machen, wie macht ihr das?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2243862</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2243862</guid><dc:creator><![CDATA[Nash26]]></dc:creator><pubDate>Mon, 20 Aug 2012 20:40:12 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Mon, 20 Aug 2012 20:42:59 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#ifdef HAS_TR1
namespace std
{
    using namespace tr1;
}
#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2243864</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2243864</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Mon, 20 Aug 2012 20:42:59 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Mon, 20 Aug 2012 20:44:23 GMT]]></title><description><![CDATA[<p>Geht nicht statt dem Dreizeiler auch einfach:</p>
<pre><code class="language-cpp">using namespace std::tr1;
</code></pre>
<p>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2243865</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2243865</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Mon, 20 Aug 2012 20:44:23 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Mon, 20 Aug 2012 21:04:56 GMT]]></title><description><![CDATA[<p>Wer hat gesagt, dass er namespace std aufloesen moechte?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2243867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2243867</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Mon, 20 Aug 2012 21:04:56 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Mon, 20 Aug 2012 21:08:33 GMT]]></title><description><![CDATA[<p>Um eine Zeile und die Makrodefinition zu sparen, geht auch folgendes:</p>
<pre><code class="language-cpp">namespace std {
  namespace tr1 {}
  using namespace tr1;
}
</code></pre>
<p>Ich bin mir nicht sicher, ob das nach Standard erlaubt ist. Es wird aber mit jedem Compiler gehen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2243868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2243868</guid><dc:creator><![CDATA[zeilenzähler]]></dc:creator><pubDate>Mon, 20 Aug 2012 21:08:33 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 05:42:19 GMT]]></title><description><![CDATA[<p>Kellerautomat schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#ifdef HAS_TR1
namespace std
{
    using namespace tr1;
}
#endif
</code></pre>
</blockquote>
<p>eventuell möchte ich halt auch einen fall back anbieten wenn es diese methoden nicht gibt. z.B. weil C++ 2005 verwendet wird.</p>
<pre><code class="language-cpp">#ifdef HAS_TR1
namespace MyNs
{
    using namespace std::tr1;
}
#endif
</code></pre>
<p>Kann es hier nicht zu Problemen kommen, weil ich das ja in einer header datei machen muss?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2243921</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2243921</guid><dc:creator><![CDATA[Nash26]]></dc:creator><pubDate>Tue, 21 Aug 2012 05:42:19 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 06:17:43 GMT]]></title><description><![CDATA[<p>Man sollte eigentlich generell kein using in Headern verwenden, aber compilieren tut es trotzdem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2243927</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2243927</guid><dc:creator><![CDATA[Cyres]]></dc:creator><pubDate>Tue, 21 Aug 2012 06:17:43 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 06:37:04 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#ifdef HAS_TR1
    namespace ns = std::tr1;
#else
    namespace ns = std;
#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2243939</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2243939</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 21 Aug 2012 06:37:04 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 07:00:45 GMT]]></title><description><![CDATA[<p>zeilenzähler schrieb:</p>
<blockquote>
<p>Um eine Zeile und die Makrodefinition zu sparen, geht auch folgendes:</p>
<pre><code class="language-cpp">namespace std {
  namespace tr1 {}
  using namespace tr1;
}
</code></pre>
<p>Ich bin mir nicht sicher, ob das nach Standard erlaubt ist. Es wird aber mit jedem Compiler gehen</p>
</blockquote>
<p>Was sollte hier nicht erlaubt sein? Die Lösung ist mir auch gleich eingefallen. Das ist sehr elegant. Und wenn das im Header steht, dann ist das in dem Fall gar nicht schlimm. Ich glaube, das ist der einzige Fall, in dem ich persönlich überhaupt &quot;using namespace&quot; verwenden würde. Ich verwende das auch nicht im cpp.</p>
<p>Nash26 schrieb:</p>
<blockquote>
<p>eventuell möchte ich halt auch einen fall back anbieten wenn es diese methoden nicht gibt. z.B. weil C++ 2005 verwendet wird.</p>
</blockquote>
<p>Was ist denn C++ 2005? Es gibt C++ 1998, 2003 und C++11, aber 2005 ist kein Standard raus gekommen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2243946</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2243946</guid><dc:creator><![CDATA[ich bins]]></dc:creator><pubDate>Tue, 21 Aug 2012 07:00:45 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 07:03:37 GMT]]></title><description><![CDATA[<p>ich bins schrieb:</p>
<blockquote>
<p>Was ist denn C++ 2005? Es gibt C++ 1998, 2003 und C++11, aber 2005 ist kein Standard raus gekommen.</p>
</blockquote>
<p>Ich denke er meint VS 2005</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2243947</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2243947</guid><dc:creator><![CDATA[firefly]]></dc:creator><pubDate>Tue, 21 Aug 2012 07:03:37 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 07:14:44 GMT]]></title><description><![CDATA[<p>ich bins schrieb:</p>
<blockquote>
<p>zeilenzähler schrieb:</p>
<blockquote>
<p>Um eine Zeile und die Makrodefinition zu sparen, geht auch folgendes:</p>
<pre><code class="language-cpp">namespace std {
  namespace tr1 {}
  using namespace tr1;
}
</code></pre>
<p>Ich bin mir nicht sicher, ob das nach Standard erlaubt ist. Es wird aber mit jedem Compiler gehen</p>
</blockquote>
<p>Was sollte hier nicht erlaubt sein?</p>
</blockquote>
<p>Man darf dem <code>namespace std</code> keine Definitionen hinzufügen. <code>namespace tr1 {}</code> ist doch eine Definition, von dem her sollte es nicht erlaubt sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2243948</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2243948</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Tue, 21 Aug 2012 07:14:44 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 09:25:59 GMT]]></title><description><![CDATA[<p>out schrieb:</p>
<blockquote>
<p>Man darf dem <code>namespace std</code> keine Definitionen hinzufügen. <code>namespace tr1 {}</code> ist doch eine Definition, von dem her sollte es nicht erlaubt sein.</p>
</blockquote>
<p>Das ist eine Konvention der Standardbibliothek, die aber vom Compiler nicht geprüft wird. Daher funktioniert das auf jeden Fall.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2244014</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2244014</guid><dc:creator><![CDATA[ich bins]]></dc:creator><pubDate>Tue, 21 Aug 2012 09:25:59 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 09:28:47 GMT]]></title><description><![CDATA[<p>ich bins schrieb:</p>
<blockquote>
<p>out schrieb:</p>
<blockquote>
<p>Man darf dem <code>namespace std</code> keine Definitionen hinzufügen. <code>namespace tr1 {}</code> ist doch eine Definition, von dem her sollte es nicht erlaubt sein.</p>
</blockquote>
<p>Das ist eine Konvention der Standardbibliothek, die aber vom Compiler nicht geprüft wird. Daher funktioniert das auf jeden Fall.</p>
</blockquote>
<p>Ja schon. Es geht aber ja auch nicht darum, ob es funktioniert oder nicht funktioniert, sondern ob es erlaubt oder nicht erlaubt ist. Das ist ein Unterschied.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2244015</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2244015</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Tue, 21 Aug 2012 09:28:47 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 15:23:35 GMT]]></title><description><![CDATA[<p>out schrieb:</p>
<blockquote>
<p>ich bins schrieb:</p>
<blockquote>
<p>out schrieb:</p>
<blockquote>
<p>Man darf dem <code>namespace std</code> keine Definitionen hinzufügen. <code>namespace tr1 {}</code> ist doch eine Definition, von dem her sollte es nicht erlaubt sein.</p>
</blockquote>
<p>Das ist eine Konvention der Standardbibliothek, die aber vom Compiler nicht geprüft wird. Daher funktioniert das auf jeden Fall.</p>
</blockquote>
<p>Ja schon. Es geht aber ja auch nicht darum, ob es funktioniert oder nicht funktioniert, sondern ob es erlaubt oder nicht erlaubt ist. Das ist ein Unterschied.</p>
</blockquote>
<p>Es ist nicht Standardkonform. Und außerdem löst es das Problem des OP nicht (im Gegensatz zur Variante mit Namensraum-Alias).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2244154</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2244154</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 21 Aug 2012 15:23:35 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 20:01:26 GMT]]></title><description><![CDATA[<p>Kellerautomat schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#ifdef HAS_TR1
namespace std
{
    using namespace tr1;
}
#endif
</code></pre>
</blockquote>
<p>Das scheint mit die einzigste Lösung zu sein.</p>
<p>Nexus schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#ifdef HAS_TR1
    namespace ns = std::tr1;
#else
    namespace ns = std;
#endif
</code></pre>
</blockquote>
<p>Hier bekomme ich eine Fehlermeldung:</p>
<blockquote>
<p>a symbol with this name already exists in the current scope</p>
</blockquote>
<p>da ich dieses Aktion in mehreren Header mache.</p>
<p>Ich hatte noch überlegt, für diese neu std Objekte die ich brauche, abzuleiten...aber wäre wohl zu viel Veränderung</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2244241</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2244241</guid><dc:creator><![CDATA[Nash26]]></dc:creator><pubDate>Tue, 21 Aug 2012 20:01:26 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 20:17:55 GMT]]></title><description><![CDATA[<p>Nash26 schrieb:</p>
<blockquote>
<p>Nexus schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#ifdef HAS_TR1
    namespace ns = std::tr1;
#else
    namespace ns = std;
#endif
</code></pre>
</blockquote>
<p>Hier bekomme ich eine Fehlermeldung:</p>
<blockquote>
<p>a symbol with this name already exists in the current scope</p>
</blockquote>
<p>da ich dieses Aktion in mehreren Header mache.</p>
</blockquote>
<p>Dann nimm doch einfach entweder einen extra-Header oder mach einen Includeguard drumherum.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2244244</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2244244</guid><dc:creator><![CDATA[wxSkip]]></dc:creator><pubDate>Tue, 21 Aug 2012 20:17:55 GMT</pubDate></item><item><title><![CDATA[Reply to std::tr1 und std:: namespace supporten, aber wie am einfachsten? on Tue, 21 Aug 2012 20:27:46 GMT]]></title><description><![CDATA[<p>Nash26 schrieb:</p>
<blockquote>
<p>Kellerautomat schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#ifdef HAS_TR1
namespace std
{
    using namespace tr1;
}
#endif
</code></pre>
</blockquote>
<p>Das scheint mit die einzigste Lösung zu sein.</p>
</blockquote>
<p>Funktioniert nur nicht. Ein std::tr1::is_function kann auch danach nicht als std::is_function angesprochen werden, da using-Direktiven keinen Einfluss auf qualifiziertes Lookup haben.</p>
<p>Nash26 schrieb:</p>
<blockquote>
<p>Nexus schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#ifdef HAS_TR1
    namespace ns = std::tr1;
#else
    namespace ns = std;
#endif
</code></pre>
</blockquote>
<p>Hier bekomme ich eine Fehlermeldung:</p>
<blockquote>
<p>a symbol with this name already exists in the current scope</p>
</blockquote>
<p>da ich dieses Aktion in mehreren Header mache.</p>
<p>Ich hatte noch überlegt, für diese neu std Objekte die ich brauche, abzuleiten...aber wäre wohl zu viel Veränderung</p>
</blockquote>
<p>Dann ist dein Compiler kaputt. Namespace-alias-Definitionen können wiederholt werden, sofern sie immer auf den gleichen Namensraum verweisen. Abgesehen davon gehören solche Dinge wohl in einen eigenen Kompatibilitätsheader, es ist also nur eine Frage der Organisation.</p>
<p>Und wenn es ur darum geht, standarkonform alles per using-Direktive hereinzuholen, kann auch ein Hilfsnamensraum dienen:</p>
<pre><code class="language-cpp">namespace std_all
{
    using namespace ::std;
#ifdef HAS_TR1
    using namespace ::std::tr1;
#endif
}
</code></pre>
<p>und dann eben std_all statt std in den using-Direktiven angeben. Ist aber nur bedingt sinnvoll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2244245</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2244245</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 21 Aug 2012 20:27:46 GMT</pubDate></item></channel></rss>