<?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[Probleme mit Boost Variant und Templates]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe folgende Definition eines Function Members eines Klassentemplates:</p>
<pre><code class="language-cpp">template&lt;class N, class PN, class C, class CC, class RC, class PC, class T&gt; PN* Base_Nd&lt;N, PN, C, CC, RC, PC, T&gt;::parent_node() const
{
	class my_visitor : public boost::static_visitor&lt;int&gt;
	{
	public:
	    int operator()(int i) const
	    {
	        return i;
	    }

	    int operator()(const std::string &amp; str) const
	    {
	        return str.length();
	    }
	};

	boost::variant&lt; int, std::string &gt; u(&quot;hello world&quot;);
	int result = boost::apply_visitor( my_visitor(), u );
}
</code></pre>
<p>Wenn ich das versuche zu kompilieren, erhalte ich die Fehlermeldung</p>
<blockquote>
<p>no matching function for call to ‘apply_visitor(Base_Nd&lt;N, PN, C, CC, RC, PC, T&gt;::parent_node() const [with N = Rev_Nd, PN = Rev_Intern_Nd, C = Rev_NC, CC = Rev_Coal_NC, RC = Rev_Rec_NC, PC = Rev_Intern_NC, T = Tree]::my_visitor, boost::variant&lt;int, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_&gt;&amp;)’</p>
</blockquote>
<p>bezüglich</p>
<pre><code class="language-cpp">int result = boost::apply_visitor( my_visitor(), u );
</code></pre>
<p>Wenn ich allerdings my_visitor aus der Funktionsdefinition rausziehe, d. h.</p>
<pre><code class="language-cpp">class my_visitor : public boost::static_visitor&lt;int&gt;
{
public:
    int operator()(int i) const
    {
        return i;
    }

    int operator()(const std::string &amp; str) const
    {
        return str.length();
    }
};

template&lt;class N, class PN, class C, class CC, class RC, class PC, class T&gt; PN* Base_Nd&lt;N, PN, C, CC, RC, PC, T&gt;::parent_node() const
{
	boost::variant&lt; int, std::string &gt; u(&quot;hello world&quot;);
	int result = boost::apply_visitor( my_visitor(), u );
}
</code></pre>
<p>kann ich fehlerfrei kompilieren. Weiss jemand, was ich tun muss, um my_visitor in die Funktionsdefinition packen zu können?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/224145/probleme-mit-boost-variant-und-templates</link><generator>RSS for Node</generator><lastBuildDate>Fri, 02 Oct 2026 18:25:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/224145.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 Oct 2008 10:19:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit Boost Variant und Templates on Mon, 06 Oct 2008 10:19:40 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe folgende Definition eines Function Members eines Klassentemplates:</p>
<pre><code class="language-cpp">template&lt;class N, class PN, class C, class CC, class RC, class PC, class T&gt; PN* Base_Nd&lt;N, PN, C, CC, RC, PC, T&gt;::parent_node() const
{
	class my_visitor : public boost::static_visitor&lt;int&gt;
	{
	public:
	    int operator()(int i) const
	    {
	        return i;
	    }

	    int operator()(const std::string &amp; str) const
	    {
	        return str.length();
	    }
	};

	boost::variant&lt; int, std::string &gt; u(&quot;hello world&quot;);
	int result = boost::apply_visitor( my_visitor(), u );
}
</code></pre>
<p>Wenn ich das versuche zu kompilieren, erhalte ich die Fehlermeldung</p>
<blockquote>
<p>no matching function for call to ‘apply_visitor(Base_Nd&lt;N, PN, C, CC, RC, PC, T&gt;::parent_node() const [with N = Rev_Nd, PN = Rev_Intern_Nd, C = Rev_NC, CC = Rev_Coal_NC, RC = Rev_Rec_NC, PC = Rev_Intern_NC, T = Tree]::my_visitor, boost::variant&lt;int, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_&gt;&amp;)’</p>
</blockquote>
<p>bezüglich</p>
<pre><code class="language-cpp">int result = boost::apply_visitor( my_visitor(), u );
</code></pre>
<p>Wenn ich allerdings my_visitor aus der Funktionsdefinition rausziehe, d. h.</p>
<pre><code class="language-cpp">class my_visitor : public boost::static_visitor&lt;int&gt;
{
public:
    int operator()(int i) const
    {
        return i;
    }

    int operator()(const std::string &amp; str) const
    {
        return str.length();
    }
};

template&lt;class N, class PN, class C, class CC, class RC, class PC, class T&gt; PN* Base_Nd&lt;N, PN, C, CC, RC, PC, T&gt;::parent_node() const
{
	boost::variant&lt; int, std::string &gt; u(&quot;hello world&quot;);
	int result = boost::apply_visitor( my_visitor(), u );
}
</code></pre>
<p>kann ich fehlerfrei kompilieren. Weiss jemand, was ich tun muss, um my_visitor in die Funktionsdefinition packen zu können?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1594105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1594105</guid><dc:creator><![CDATA[ingobulla]]></dc:creator><pubDate>Mon, 06 Oct 2008 10:19:40 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit Boost Variant und Templates on Mon, 06 Oct 2008 10:48:11 GMT]]></title><description><![CDATA[<p>ingobulla schrieb:</p>
<blockquote>
<p>Weiss jemand, was ich tun muss, um my_visitor in die Funktionsdefinition packen zu können?</p>
</blockquote>
<p>Den Standard ändern. Sprich: Das ist nicht erlaubt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1594120</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1594120</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Mon, 06 Oct 2008 10:48:11 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit Boost Variant und Templates on Mon, 06 Oct 2008 10:54:21 GMT]]></title><description><![CDATA[<p>Gegen welche Regel verstoße ich denn hier?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1594124</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1594124</guid><dc:creator><![CDATA[ingobulla]]></dc:creator><pubDate>Mon, 06 Oct 2008 10:54:21 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit Boost Variant und Templates on Mon, 06 Oct 2008 11:19:44 GMT]]></title><description><![CDATA[<p>ingobulla schrieb:</p>
<blockquote>
<p>Gegen welche Regel verstoße ich denn hier?</p>
</blockquote>
<p>dass template parameter external linkage haben müssen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1594131</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1594131</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Mon, 06 Oct 2008 11:19:44 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit Boost Variant und Templates on Wed, 08 Oct 2008 08:41:03 GMT]]></title><description><![CDATA[<p>Shade Of Mine schrieb:</p>
<blockquote>
<p>dass template parameter external linkage haben müssen</p>
</blockquote>
<p>Trotz längerer Reflektionsphase war ich nicht in der Lage, das in Bezug auf meinen Code zu verstehen. Kann das irgendwer erläutern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1595323</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595323</guid><dc:creator><![CDATA[ingobulla]]></dc:creator><pubDate>Wed, 08 Oct 2008 08:41:03 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit Boost Variant und Templates on Wed, 08 Oct 2008 08:53:06 GMT]]></title><description><![CDATA[<blockquote>
<p>You can use a local class in most places where you can use a nonlocal class, but there is a major restriction to keep in mind: A local or unnamed class cannot be used as a template parameter. From the C++ standard (14.3.1/2):</p>
</blockquote>
<p>Das obige Zitat stammt von dieser Seite, Punkt 2.<br />
<a href="http://www.gotw.ca/gotw/058.htm" rel="nofollow">http://www.gotw.ca/gotw/058.htm</a></p>
<p>Simon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1595331</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595331</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Wed, 08 Oct 2008 08:53:06 GMT</pubDate></item></channel></rss>