<?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[Werden Template Template Parameter von Visual Studio 2012 unterstützt?]]></title><description><![CDATA[<p>Werden Template Template Parameter von Visual Studio 2012 unterstützt?</p>
<p>Folgendes Programm compiliert bei mir nicht in VS2012:</p>
<p>main.cpp:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;stdexcept&gt;
#include &lt;vector&gt;
#include &lt;list&gt;

using namespace std;

template&lt;typename T, template &lt;typename S&gt; class Collection&gt;
class MyCollection 
{
private:
   typedef Collection&lt;T&gt; Items;
   Items items_;        

public:
   void add(T const&amp; t) 
   { 
      items_.push_back(t); 
   }

   T get(int index) const
   {
      typedef typename Items::const_iterator Iter;
      for(Iter i = items_.begin(); i != items_.end(); ++i, --index)
      {
         if(index == 0)
            return *i;
      }

      throw runtime_error(&quot;Index out of bounds&quot;);
   }

   void clear()
   {
      items_.clear();
   }

   int size() const
   {
      return items_.size();
   }
};

int main(int argc, char* argv)
{
   MyCollection&lt;int,vector&gt; integers;
   integers.add(3); 
   integers.add(4);
   integers.add(5);

   cout &lt;&lt; integers.get(0) &lt;&lt; ',' &lt;&lt; integers.get(1) &lt;&lt; ',' 
      &lt;&lt; integers.get(2) &lt;&lt; endl;

   MyCollection&lt;string,list&gt; strings;
   strings.add(&quot;three&quot;); 
   strings.add(&quot;four&quot;);
   strings.add(&quot;five&quot;);

   cout &lt;&lt; strings.get(0) &lt;&lt; ',' &lt;&lt; strings.get(1) &lt;&lt; ',' 
      &lt;&lt; strings.get(2) &lt;&lt; endl;

   return 0;
}
</code></pre>
<p>Fehler:<br />
Error 1 error C3201: the template parameter list for class template 'std::vector' does not match the template parameter list for template parameter 'Collection' main.cpp 46 Testbed</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/312163/werden-template-template-parameter-von-visual-studio-2012-unterstützt</link><generator>RSS for Node</generator><lastBuildDate>Mon, 03 Aug 2026 02:04:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/312163.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 27 Dec 2012 10:14:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Werden Template Template Parameter von Visual Studio 2012 unterstützt? on Thu, 27 Dec 2012 10:14:33 GMT]]></title><description><![CDATA[<p>Werden Template Template Parameter von Visual Studio 2012 unterstützt?</p>
<p>Folgendes Programm compiliert bei mir nicht in VS2012:</p>
<p>main.cpp:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;stdexcept&gt;
#include &lt;vector&gt;
#include &lt;list&gt;

using namespace std;

template&lt;typename T, template &lt;typename S&gt; class Collection&gt;
class MyCollection 
{
private:
   typedef Collection&lt;T&gt; Items;
   Items items_;        

public:
   void add(T const&amp; t) 
   { 
      items_.push_back(t); 
   }

   T get(int index) const
   {
      typedef typename Items::const_iterator Iter;
      for(Iter i = items_.begin(); i != items_.end(); ++i, --index)
      {
         if(index == 0)
            return *i;
      }

      throw runtime_error(&quot;Index out of bounds&quot;);
   }

   void clear()
   {
      items_.clear();
   }

   int size() const
   {
      return items_.size();
   }
};

int main(int argc, char* argv)
{
   MyCollection&lt;int,vector&gt; integers;
   integers.add(3); 
   integers.add(4);
   integers.add(5);

   cout &lt;&lt; integers.get(0) &lt;&lt; ',' &lt;&lt; integers.get(1) &lt;&lt; ',' 
      &lt;&lt; integers.get(2) &lt;&lt; endl;

   MyCollection&lt;string,list&gt; strings;
   strings.add(&quot;three&quot;); 
   strings.add(&quot;four&quot;);
   strings.add(&quot;five&quot;);

   cout &lt;&lt; strings.get(0) &lt;&lt; ',' &lt;&lt; strings.get(1) &lt;&lt; ',' 
      &lt;&lt; strings.get(2) &lt;&lt; endl;

   return 0;
}
</code></pre>
<p>Fehler:<br />
Error 1 error C3201: the template parameter list for class template 'std::vector' does not match the template parameter list for template parameter 'Collection' main.cpp 46 Testbed</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2283558</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2283558</guid><dc:creator><![CDATA[Uniquen343]]></dc:creator><pubDate>Thu, 27 Dec 2012 10:14:33 GMT</pubDate></item><item><title><![CDATA[Reply to Werden Template Template Parameter von Visual Studio 2012 unterstützt? on Thu, 27 Dec 2012 10:24:04 GMT]]></title><description><![CDATA[<p>vector besitzt eine unspezifizierte anzahl von templateparametern, aber mindestens 2. Für template-template parameter musst du aber immer die exakte Anzahl angeben *inklusive* der Parameter mit Default-Wert.</p>
<p>Das was du machen willst, funktioniert also nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2283560</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2283560</guid><dc:creator><![CDATA[otze]]></dc:creator><pubDate>Thu, 27 Dec 2012 10:24:04 GMT</pubDate></item><item><title><![CDATA[Reply to Werden Template Template Parameter von Visual Studio 2012 unterstützt? on Thu, 27 Dec 2012 11:03:34 GMT]]></title><description><![CDATA[<p>otze schrieb:</p>
<blockquote>
<p>Für template-template parameter musst du aber immer die exakte Anzahl angeben *inklusive* der Parameter mit Default-Wert.</p>
</blockquote>
<p>Hat mich auch schon häufiger geärgert. Gibt es einen nachvollziehbaren Grund, warum man Parametern mit Default-Werten angeben muss?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2283572</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2283572</guid><dc:creator><![CDATA[Betatester]]></dc:creator><pubDate>Thu, 27 Dec 2012 11:03:34 GMT</pubDate></item></channel></rss>