<?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[explicit initialization of a template function]]></title><description><![CDATA[<pre><code class="language-cpp">template &lt;class TList&gt;
class TypesConvertor
{
public:
   ... //Andere Funktionen

   template &lt;class T&gt; 
   struct isRegistred   
    : mpl::not_&lt;
        typename boost::is_same&lt;
            typename mpl::find&lt;TList, T&gt;::type, typename mpl::end&lt;TList&gt;::type 
        &gt;::type 
    &gt;
   { };

   template &lt;class T&gt;
   typename boost::enable_if&lt;isRegistred&lt;T&gt;, T&gt;::type getFromStack(lua_State*, int idx)
   {
      //...
   }
};

template &lt;class TList&gt;
template &lt;&gt; int TypesConvertor&lt;TList&gt;::getFromStack&lt;int&gt;(lua_State*, int idx)
{
...
}
</code></pre>
<p>So funktioniert es nicht: gcc 4.4 sagt, dass</p>
<blockquote>
<p>invalid explicit specialization before '&gt;' token ..enclosing class templates are not explicitly specialized</p>
</blockquote>
<p>Das kann man verstehen, denn</p>
<blockquote>
<p>&quot;the declaration shall not explicitly specialize a class member template if its enclosing class templates are not explicitly specialized as well&quot;</p>
</blockquote>
<p>Gibt es Ideen, wie man das Programm zum laufen bringen kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/252304/explicit-initialization-of-a-template-function</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 13:27:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/252304.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 17 Oct 2009 20:13:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to explicit initialization of a template function on Sat, 17 Oct 2009 20:13:41 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">template &lt;class TList&gt;
class TypesConvertor
{
public:
   ... //Andere Funktionen

   template &lt;class T&gt; 
   struct isRegistred   
    : mpl::not_&lt;
        typename boost::is_same&lt;
            typename mpl::find&lt;TList, T&gt;::type, typename mpl::end&lt;TList&gt;::type 
        &gt;::type 
    &gt;
   { };

   template &lt;class T&gt;
   typename boost::enable_if&lt;isRegistred&lt;T&gt;, T&gt;::type getFromStack(lua_State*, int idx)
   {
      //...
   }
};

template &lt;class TList&gt;
template &lt;&gt; int TypesConvertor&lt;TList&gt;::getFromStack&lt;int&gt;(lua_State*, int idx)
{
...
}
</code></pre>
<p>So funktioniert es nicht: gcc 4.4 sagt, dass</p>
<blockquote>
<p>invalid explicit specialization before '&gt;' token ..enclosing class templates are not explicitly specialized</p>
</blockquote>
<p>Das kann man verstehen, denn</p>
<blockquote>
<p>&quot;the declaration shall not explicitly specialize a class member template if its enclosing class templates are not explicitly specialized as well&quot;</p>
</blockquote>
<p>Gibt es Ideen, wie man das Programm zum laufen bringen kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1793982</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1793982</guid><dc:creator><![CDATA[CppCoder]]></dc:creator><pubDate>Sat, 17 Oct 2009 20:13:41 GMT</pubDate></item><item><title><![CDATA[Reply to explicit initialization of a template function on Sat, 17 Oct 2009 20:46:06 GMT]]></title><description><![CDATA[<p>Du könntest die Spezialisierung in der Definition von TypesConvertor definieren, ggf. indem du dort eine nicht-template-Funktion aufrufst. Oder du löst das ganze per Überladung, d.h.</p>
<pre><code class="language-cpp">template &lt;class TList&gt;
class TypesConvertor
{
public:
   ...
   template &lt;class T&gt;
   typename boost::enable_if&lt;boost::mpl::and_&lt;isRegistred&lt;T&gt;,boost::mpl::not_&lt;boost::is_same&lt;T,int&gt;&gt;&gt;,T&gt;::type getFromStack(lua_State*, int idx);
   template &lt;class T&gt;
   typename boost::enable_if&lt;boost::mpl::and_&lt;isRegistred&lt;T&gt;,boost::is_same&lt;T,int&gt;&gt;,T&gt;::type getFromStack(lua_State*, int idx);
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1793995</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1793995</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sat, 17 Oct 2009 20:46:06 GMT</pubDate></item><item><title><![CDATA[Reply to explicit initialization of a template function on Sat, 17 Oct 2009 20:54:48 GMT]]></title><description><![CDATA[<blockquote>
<p>indem du dort eine nicht-template-Funktion aufrufst</p>
</blockquote>
<p>Beispiel?</p>
<pre><code class="language-cpp">template &lt;class TList&gt;
class TypesConvertor
{
public:
   ...
   template &lt;class T&gt;
   typename boost::enable_if&lt;boost::mpl::and_&lt;isRegistred&lt;T&gt;,boost::mpl::not_&lt;boost::is_same&lt;T,int&gt;&gt;&gt;,T&gt;::type getFromStack(lua_State*, int idx);
   template &lt;class T&gt;
   typename boost::enable_if&lt;boost::mpl::and_&lt;isRegistred&lt;T&gt;,boost::is_same&lt;T,int&gt;&gt;,T&gt;::type getFromStack(lua_State*, int idx);
};
</code></pre>
<p>Dies fürchte ich wird nicht klappen, denn außer der Überladung mit &quot;int&quot; gibt es noch zahlreiche andere. Es wird sehr schnell schrecklich aussehen..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1794000</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1794000</guid><dc:creator><![CDATA[CppCoder]]></dc:creator><pubDate>Sat, 17 Oct 2009 20:54:48 GMT</pubDate></item><item><title><![CDATA[Reply to explicit initialization of a template function on Sat, 17 Oct 2009 20:58:08 GMT]]></title><description><![CDATA[<p>CppCoder schrieb:</p>
<blockquote>
<p>denn außer der Überladung mit &quot;int&quot; gibt es noch zahlreiche andere.</p>
</blockquote>
<p>für jeden einzelnen potentiell registrierten Typ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1794001</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1794001</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sat, 17 Oct 2009 20:58:08 GMT</pubDate></item><item><title><![CDATA[Reply to explicit initialization of a template function on Sat, 17 Oct 2009 21:07:11 GMT]]></title><description><![CDATA[<blockquote>
<p>für jeden einzelnen potentiell registrierten Typ?</p>
</blockquote>
<p>nein, in TList werden nur Objekttypen(Klassen) registriert. es ist so gedacht, dass sie mit einer generic-funktion &quot;template &lt;class T&gt; ... getFromStack(...)&quot; die in der Klass Scope liegt, verarbeitet werden. Für alle andere Typen( Zahlentypen wie int float... const char*) soll es eigene Überladungen geben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1794005</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1794005</guid><dc:creator><![CDATA[CppCoder]]></dc:creator><pubDate>Sat, 17 Oct 2009 21:07:11 GMT</pubDate></item><item><title><![CDATA[Reply to explicit initialization of a template function on Sat, 17 Oct 2009 21:16:28 GMT]]></title><description><![CDATA[<p>Explizite Memberspezialisierungen ohne explizite Spezialisierung des äußeren Templates sind verboten, eine vergleichbare Regel existiert nicht für partielle Spezialisierungen. Man könnte also so etwas machen:</p>
<pre><code class="language-cpp">template &lt;class TList&gt;
class TypesConvertor
{
public:
   ... //Andere Funktionen

   template &lt;class T&gt;
   struct isRegistred : boost::mpl::contains&lt;TList,T&gt;::type {};

   template &lt;class T&gt;
   typename boost::enable_if&lt;isRegistred&lt;T&gt;, T&gt;::type getFromStack(lua_State* state, int idx)
   {
      GetFromStack&lt;T,void&gt;()(this, state, idx);
   }
private:
   template &lt;typename T, typename dummy&gt;
   struct GetFromStack
   {
       T operator()(TypesConvertor* p, lua_State* state, int idx)
       {
           ...
       }
   };
   template &lt;typename T, typename dummy&gt;
   friend struct GetFromStack;
};

template &lt;typename TList&gt;
template &lt;typename dummy&gt;
struct TypesConvertor&lt;TList&gt;::GetFromStack&lt;int, dummy&gt;
{
   int operator()(TypesConvertor* p, lua_State* state, int idx)
   {
       ...
   }
};
</code></pre>
<p>ist auch nicht besonders schön.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1794007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1794007</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sat, 17 Oct 2009 21:16:28 GMT</pubDate></item></channel></rss>