<?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[template typedef]]></title><description><![CDATA[<p>Hallo,<br />
wie kann ich sowas in der Art verwirklichen?</p>
<pre><code class="language-cpp">typedef std::vector&lt;T&gt; MyVector&lt;T&gt;;
// oder
typedef std::vector MyVector;
</code></pre>
<p>Muss ich dafür ein Makro nehmen, oder kann ich das irgendwie mit einem typedef lösen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/290964/template-typedef</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 00:21:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/290964.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 07 Aug 2011 22:41:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to template typedef on Sun, 07 Aug 2011 22:41:45 GMT]]></title><description><![CDATA[<p>Hallo,<br />
wie kann ich sowas in der Art verwirklichen?</p>
<pre><code class="language-cpp">typedef std::vector&lt;T&gt; MyVector&lt;T&gt;;
// oder
typedef std::vector MyVector;
</code></pre>
<p>Muss ich dafür ein Makro nehmen, oder kann ich das irgendwie mit einem typedef lösen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103188</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103188</guid><dc:creator><![CDATA[Templamator]]></dc:creator><pubDate>Sun, 07 Aug 2011 22:41:45 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Sun, 07 Aug 2011 22:53:09 GMT]]></title><description><![CDATA[<p>Template typedefs gibt's nicht in C++. Aber im neuen Standard wird's voraussichtlich drin sein, vielleicht kann's dein Compiler schon mit den richtigen Schaltern.. Bis dahin ist dies der übliche Workaround:</p>
<pre><code class="language-cpp">#include &lt;vector&gt;

template&lt;class T&gt; struct MyVector
{
  typedef std::vector&lt;T&gt; Type;
};

int main()
{
  MyVector&lt;int&gt;::Type foo;
}
</code></pre>
<p>Für C++0x, guckst du hier:<br />
<a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Template_aliases" rel="nofollow">http://en.wikipedia.org/wiki/C%2B%2B0x#Template_aliases</a><br />
Ob dein Compiler das kann und wenn ja wie, guckste bei Google.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103191</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103191</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 07 Aug 2011 22:53:09 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Sun, 07 Aug 2011 23:05:55 GMT]]></title><description><![CDATA[<p>Soweit man google glauben kann, wird dieses Feature weder im GCC noch beim MSVC unterstützt. Und das Workaround vermehrt die Tipparbeit ja sogar manchmal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
Ich habe jetzt einfach ein Makro genommen, ist zwar nicht so schön, aber erfüllt seinen Zweck besser.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103197</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103197</guid><dc:creator><![CDATA[Templamator]]></dc:creator><pubDate>Sun, 07 Aug 2011 23:05:55 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Mon, 08 Aug 2011 08:46:29 GMT]]></title><description><![CDATA[<p>Du machst den Typedef nur zum Sparen von Tipparbeit? <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=":confused:"
      alt="😕"
    /> Dann mach doch <code>using std::vector</code> und du hast nur 5 Buchstaben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103282</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103282</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 08 Aug 2011 08:46:29 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Mon, 08 Aug 2011 09:00:27 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Template typedefs gibt's nicht in C++. Aber im neuen Standard wird's voraussichtlich drin sein</p>
</blockquote>
<p>Cool...<br />
Das wußte ich auch noch nicht <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>Leider unterstützt selbst die Version 4.7 des GCC es leider noch nicht:<br />
<a href="http://gcc.gnu.org/gcc-4.7/cxx0x_status.html" rel="nofollow">http://gcc.gnu.org/gcc-4.7/cxx0x_status.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103290</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103290</guid><dc:creator><![CDATA[XSpille]]></dc:creator><pubDate>Mon, 08 Aug 2011 09:00:27 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Mon, 08 Aug 2011 09:29:42 GMT]]></title><description><![CDATA[<p>XSpille schrieb:</p>
<blockquote>
<p>Leider unterstützt selbst die Version 4.7 des GCC es leider noch nicht:<br />
<a href="http://gcc.gnu.org/gcc-4.7/cxx0x_status.html" rel="nofollow">http://gcc.gnu.org/gcc-4.7/cxx0x_status.html</a></p>
</blockquote>
<p>Anscheinend aber in einem seperaten Patch.<br />
Wenns nur für dich ist, teste den doch mal. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/2103305</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103305</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Mon, 08 Aug 2011 09:29:42 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Mon, 08 Aug 2011 10:25:59 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Du machst den Typedef nur zum Sparen von Tipparbeit? <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=":confused:"
      alt="😕"
    /> Dann mach doch <code>using std::vector</code> und du hast nur 5 Buchstaben.</p>
</blockquote>
<p>Ne ich möchte nur aus einem _irgendein_typ_nochwas_t&lt;T&gt; ein MeinTyp&lt;T&gt; machen <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/2103334</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103334</guid><dc:creator><![CDATA[Templamator]]></dc:creator><pubDate>Mon, 08 Aug 2011 10:25:59 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Mon, 08 Aug 2011 11:40:34 GMT]]></title><description><![CDATA[<p>Das bietet doch der obige Workaround. Die Namen kannste so kurz wählen wie du möchtest. Z.B. <code>Mein&lt;int&gt;::Type</code> oder <code>_&lt;int&gt;::_</code> :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103369</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103369</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 08 Aug 2011 11:40:34 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Mon, 08 Aug 2011 12:04:58 GMT]]></title><description><![CDATA[<p>Templamator schrieb:</p>
<blockquote>
<p>Hallo,<br />
wie kann ich sowas in der Art verwirklichen?</p>
<pre><code class="language-cpp">typedef std::vector&lt;T&gt; MyVector&lt;T&gt;;
// oder
typedef std::vector MyVector;
</code></pre>
</blockquote>
<p>Im Moment gar nicht. Später soll das dann mal so aussehen:</p>
<pre><code class="language-cpp">using MyReal = double; // alternativ: typedef double MyReal;

template&lt;class T&gt;
using MyVector = std::vector&lt;T&gt;; // geht nicht anders
</code></pre>
<p>Ich habe gehört, dass das <a href="http://clang.llvm.org/" rel="nofollow">Clang</a> schon kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103389</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103389</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Mon, 08 Aug 2011 12:04:58 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Mon, 08 Aug 2011 12:51:25 GMT]]></title><description><![CDATA[<p>krümelkacker schrieb:</p>
<blockquote>
<p>Ich habe gehört, dass das <a href="http://clang.llvm.org/" rel="nofollow">Clang</a> schon kann.</p>
</blockquote>
<p>Nicht laut dem hier: <a href="http://wiki.apache.org/stdcxx/C++0xCompilerSupport" rel="nofollow">http://wiki.apache.org/stdcxx/C++0xCompilerSupport</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103404</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103404</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Mon, 08 Aug 2011 12:51:25 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Mon, 08 Aug 2011 13:05:13 GMT]]></title><description><![CDATA[<p>meistens geht auch</p>
<pre><code class="language-cpp">template&lt;class T&gt; struct MyVector:public std::vector&lt;T&gt;{};

int main()
{
  MyVector&lt;int&gt; foo;
}
</code></pre>
<p>Kommt drauf an in welchem Umfeld sich dein Typ befindet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103408</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103408</guid><dc:creator><![CDATA[otze]]></dc:creator><pubDate>Mon, 08 Aug 2011 13:05:13 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Mon, 08 Aug 2011 13:09:32 GMT]]></title><description><![CDATA[<p>otze schrieb:</p>
<blockquote>
<p>meistens geht auch [...]</p>
</blockquote>
<p>Und meistens ist das ein schmutziger Hack, den die paar Zeichen, die man dadurch weniger tippen muss, nicht rechtfertigen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103409</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103409</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Mon, 08 Aug 2011 13:09:32 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Mon, 08 Aug 2011 15:19:31 GMT]]></title><description><![CDATA[<p>Ethon schrieb:</p>
<blockquote>
<p>krümelkacker schrieb:</p>
<blockquote>
<p>Ich habe gehört, dass das <a href="http://clang.llvm.org/" rel="nofollow">Clang</a> schon kann.</p>
</blockquote>
<p>Nicht laut dem hier: <a href="http://wiki.apache.org/stdcxx/C++0xCompilerSupport" rel="nofollow">http://wiki.apache.org/stdcxx/C++0xCompilerSupport</a></p>
</blockquote>
<p>Dieser Seite schenke in, was Clang angeht, weniger vertrauen als der hier:<br />
<a href="http://clang.llvm.org/cxx_status.html" rel="nofollow">http://clang.llvm.org/cxx_status.html</a><br />
<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>
]]></description><link>https://www.c-plusplus.net/forum/post/2103501</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103501</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Mon, 08 Aug 2011 15:19:31 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Mon, 08 Aug 2011 18:47:29 GMT]]></title><description><![CDATA[<p>Diesen Hack nutzt QT aber auch ständig. Nämlich, wenn eine Klasse außerhalb dessen auch im Namespace landen soll. Dort gibt es aber keine Klassentemplates, weswegen das eigentlich seltsam ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103609</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Mon, 08 Aug 2011 18:47:29 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Tue, 09 Aug 2011 10:58:22 GMT]]></title><description><![CDATA[<p>pumuckl schrieb:</p>
<blockquote>
<p>otze schrieb:</p>
<blockquote>
<p>meistens geht auch [...]</p>
</blockquote>
<p>Und meistens ist das ein schmutziger Hack, den die paar Zeichen, die man dadurch weniger tippen muss, nicht rechtfertigen.</p>
</blockquote>
<p>Ja. Hat aber den Vorteil, dass es an vielen Stellen zu lesbareren Compilerfehlermeldungen führt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103859</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103859</guid><dc:creator><![CDATA[otze]]></dc:creator><pubDate>Tue, 09 Aug 2011 10:58:22 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Tue, 09 Aug 2011 11:26:20 GMT]]></title><description><![CDATA[<p>Ach Compilerfehlermeldungen find ich überbewertet. Ich meine, wenn da ein 16-Zeiler an Templatemeldungen erscheint, geh ich ans Ende und bin auch sofort da.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103865</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103865</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Tue, 09 Aug 2011 11:26:20 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Tue, 09 Aug 2011 11:33:01 GMT]]></title><description><![CDATA[<p>otze schrieb:</p>
<blockquote>
<p>Ja. Hat aber den Vorteil, dass es an vielen Stellen zu lesbareren Compilerfehlermeldungen führt.</p>
</blockquote>
<p>Nö, es fügt nur eine zusätzliche Zeile in den Template-Fehlerstack ein. Und potentielle Fehler einzubauen, damit man Compilerfehler ein bisschen leichter entziffern kann ist nicht wirklich ein Grund, oder? <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>
]]></description><link>https://www.c-plusplus.net/forum/post/2103867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103867</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 09 Aug 2011 11:33:01 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Tue, 09 Aug 2011 11:35:41 GMT]]></title><description><![CDATA[<p>Aber was ist der Nachteil an diesem Hack?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103868</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Tue, 09 Aug 2011 11:35:41 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Tue, 09 Aug 2011 11:45:04 GMT]]></title><description><![CDATA[<p>Eisflamme schrieb:</p>
<blockquote>
<p>Aber was ist der Nachteil an diesem Hack?</p>
</blockquote>
<p>Dass Klassen wie z.B. std::vector nicht als Basisklassen vorgesehen sind und daher auch keine Rücksicht auf etwaige Kindklassen nehmen. Grundsätzlich sollte man Dinge nicht für etwas benutzen, wofür sie nicht vorgesehen sind, da es sonst eben unvorhersehbare Fehler geben kann. Und dann ist das ein klarer Fall von &quot;selber Schuld&quot; und man steht allein im Regen.<br />
Selbst wenn das für die viele Klassentemplates ein sehr kleines Risiko ist, wozu es eingehen, wenn man gegenüber den Alternativen keinen nennenswerten Gewinn davon hat? Zumal solche Dinge zwar auf den ersten Blick die Schreibarbeit und meinetwegen auch das Lesen von Compilerfehlern erleichtern, andererseits aber die Wartbarkeit vermindern, weil der Kollege, der sich den Mist in 3 Monaten anschaut, sich erstmal am Kopf kratzt und sich fragt warum zum Henker man sowas unübliches gemacht hat und nach dem Clou dahinter sucht, der nicht existiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103875</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103875</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 09 Aug 2011 11:45:04 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Tue, 09 Aug 2011 11:53:37 GMT]]></title><description><![CDATA[<p>Okay, okay, bin überzeugt. <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/2103885</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103885</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Tue, 09 Aug 2011 11:53:37 GMT</pubDate></item><item><title><![CDATA[Reply to template typedef on Tue, 09 Aug 2011 11:57:50 GMT]]></title><description><![CDATA[<p>Mal davon abgesehen, muss man alle Konstruktoren neu schreiben und an die Basisklasse vorwärtsen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103892</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103892</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Tue, 09 Aug 2011 11:57:50 GMT</pubDate></item></channel></rss>