<?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[Unverständlicher Templatefehler]]></title><description><![CDATA[<p>Hallo.<br />
Beim kompilieren meines Projektes treten immer wieder Templatefehler auf, deren Ursache nicht ausfindig machen kann.</p>
<blockquote>
<p>1&gt;c:\program files (x86)\microsoft visual studio 10.0\vc\include\sstream(724): error C2248: 'std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios' : cannot access private member declared in class 'std::basic_ios&lt;_Elem,_Traits&gt;'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; c:\program files (x86)\microsoft visual studio 10.0\vc\include\ios(176) : see declaration of 'std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; This diagnostic occurred in the compiler generated function 'std::basic_stringstream&lt;_Elem,_Traits,_Alloc&gt;::basic_stringstream(const std::basic_stringstream&lt;_Elem,_Traits,_Alloc&gt; &amp;)'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;,<br />
1&gt; _Alloc=std::allocator&lt;char&gt;<br />
1&gt; ]</p>
</blockquote>
<p>Ich weiß dass der Fehler in dem Copy-Constructor von stringstream auftritt ... allerdings werden in dem Projekt an keiner Stelle stringstreams kopiert!</p>
<p>In meinem Projekt werden außer in dieser Klasse KEINE Streams der STL genutzt:</p>
<pre><code class="language-cpp">class WinException : public std::exception
{
public:

	/**
	*Constructor
	*Prepares error information
	*@param causedIn Where did the error happen?
	*@param failedName Which WinAPI-function failed?
	*@param errorCode What does GetLastError say?
	*/
	WinException(	const std::string&amp; causedIn,
						const std::string&amp; failedName,
						DWORD errorCode) :	causedIn_(causedIn),
													failedName_(failedName),
													errorCode_(errorCode)
	{
		//Create a describing error string
		char* errString;
		DWORD ec = FormatMessageA(	FORMAT_MESSAGE_ALLOCATE_BUFFER |
											FORMAT_MESSAGE_FROM_SYSTEM,
											NULL,
											errorCode,
											0,
											errString,
											0,
											NULL);

		//Format a meaningfull error message
		formattedError_ &lt;&lt; causedIn_ &lt;&lt; &quot; Error : &quot; &lt;&lt; failedName_ &lt;&lt;
		&quot; failed with errorcode &quot; &lt;&lt; errorCode_ &lt;&lt; &quot;(&quot; &lt;&lt; 
		(ec ? errString : &quot;Unknown Error&quot;) &lt;&lt; &quot;)&quot;;

		LocalFree(errString);
	}

	/**
	*@return A formatted error message
	*/
	const char* what() const
	{
		return formattedError_.str().c_str();
	}

	/**
	*@return Where did the error happen?
	*/
	const std::string&amp; causedIn() const
	{
		return causedIn_;
	}

	/**
	*@return Which WinAPI-function failed?
	*/
	const std::string&amp; failedName() const
	{
		return failedName_;
	}

	/**
	*@return What does GetLastError say?
	*/
	DWORD errorCode() const
	{
		return errorCode_;
	}

protected:

	std::stringstream formattedError_;
	std::string causedIn_;
	std::string failedName_;
	DWORD errorCode_;
};
</code></pre>
<p>Bin gerade echt ratlos.<br />
Mfg,<br />
Flo <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/topic/274733/unverständlicher-templatefehler</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 07:05:53 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/274733.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 01 Oct 2010 17:36:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Unverständlicher Templatefehler on Fri, 01 Oct 2010 17:36:39 GMT]]></title><description><![CDATA[<p>Hallo.<br />
Beim kompilieren meines Projektes treten immer wieder Templatefehler auf, deren Ursache nicht ausfindig machen kann.</p>
<blockquote>
<p>1&gt;c:\program files (x86)\microsoft visual studio 10.0\vc\include\sstream(724): error C2248: 'std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios' : cannot access private member declared in class 'std::basic_ios&lt;_Elem,_Traits&gt;'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; c:\program files (x86)\microsoft visual studio 10.0\vc\include\ios(176) : see declaration of 'std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;<br />
1&gt; ]<br />
1&gt; This diagnostic occurred in the compiler generated function 'std::basic_stringstream&lt;_Elem,_Traits,_Alloc&gt;::basic_stringstream(const std::basic_stringstream&lt;_Elem,_Traits,_Alloc&gt; &amp;)'<br />
1&gt; with<br />
1&gt; [<br />
1&gt; _Elem=char,<br />
1&gt; _Traits=std::char_traits&lt;char&gt;,<br />
1&gt; _Alloc=std::allocator&lt;char&gt;<br />
1&gt; ]</p>
</blockquote>
<p>Ich weiß dass der Fehler in dem Copy-Constructor von stringstream auftritt ... allerdings werden in dem Projekt an keiner Stelle stringstreams kopiert!</p>
<p>In meinem Projekt werden außer in dieser Klasse KEINE Streams der STL genutzt:</p>
<pre><code class="language-cpp">class WinException : public std::exception
{
public:

	/**
	*Constructor
	*Prepares error information
	*@param causedIn Where did the error happen?
	*@param failedName Which WinAPI-function failed?
	*@param errorCode What does GetLastError say?
	*/
	WinException(	const std::string&amp; causedIn,
						const std::string&amp; failedName,
						DWORD errorCode) :	causedIn_(causedIn),
													failedName_(failedName),
													errorCode_(errorCode)
	{
		//Create a describing error string
		char* errString;
		DWORD ec = FormatMessageA(	FORMAT_MESSAGE_ALLOCATE_BUFFER |
											FORMAT_MESSAGE_FROM_SYSTEM,
											NULL,
											errorCode,
											0,
											errString,
											0,
											NULL);

		//Format a meaningfull error message
		formattedError_ &lt;&lt; causedIn_ &lt;&lt; &quot; Error : &quot; &lt;&lt; failedName_ &lt;&lt;
		&quot; failed with errorcode &quot; &lt;&lt; errorCode_ &lt;&lt; &quot;(&quot; &lt;&lt; 
		(ec ? errString : &quot;Unknown Error&quot;) &lt;&lt; &quot;)&quot;;

		LocalFree(errString);
	}

	/**
	*@return A formatted error message
	*/
	const char* what() const
	{
		return formattedError_.str().c_str();
	}

	/**
	*@return Where did the error happen?
	*/
	const std::string&amp; causedIn() const
	{
		return causedIn_;
	}

	/**
	*@return Which WinAPI-function failed?
	*/
	const std::string&amp; failedName() const
	{
		return failedName_;
	}

	/**
	*@return What does GetLastError say?
	*/
	DWORD errorCode() const
	{
		return errorCode_;
	}

protected:

	std::stringstream formattedError_;
	std::string causedIn_;
	std::string failedName_;
	DWORD errorCode_;
};
</code></pre>
<p>Bin gerade echt ratlos.<br />
Mfg,<br />
Flo <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/1960218</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1960218</guid><dc:creator><![CDATA[Icematix]]></dc:creator><pubDate>Fri, 01 Oct 2010 17:36:39 GMT</pubDate></item><item><title><![CDATA[Reply to Unverständlicher Templatefehler on Fri, 01 Oct 2010 17:42:32 GMT]]></title><description><![CDATA[<p>Ausnahme-Objekte müssen kopierbar sein. Daher kannst Du da keinen stream reinpacken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1960220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1960220</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Fri, 01 Oct 2010 17:42:32 GMT</pubDate></item><item><title><![CDATA[Reply to Unverständlicher Templatefehler on Fri, 01 Oct 2010 17:47:25 GMT]]></title><description><![CDATA[<p>krümelkacker schrieb:</p>
<blockquote>
<p>Ausnahme-Objekte müssen kopierbar sein. Daher kannst Du da keinen stream reinpacken.</p>
</blockquote>
<p>Da der Compiler einen 'std::basic_stringstream&lt;_Elem,_Traits,_Alloc&gt;::basic_stringstream(const std::basic_stringstream&lt;_Elem,_Traits,_Alloc&gt; &amp;)' erzeugt, scheint ein stringstream im Gegensatz zu fstream etc kopierbar zu sein, oder irre ich mich da?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1960221</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1960221</guid><dc:creator><![CDATA[Icematix]]></dc:creator><pubDate>Fri, 01 Oct 2010 17:47:25 GMT</pubDate></item><item><title><![CDATA[Reply to Unverständlicher Templatefehler on Fri, 01 Oct 2010 18:08:41 GMT]]></title><description><![CDATA[<p>Nein, du irrst -) Nur weil ein Objekt einer Klasse erzeugt werden kann, so muß es noch lange nicht kopierbar sein.</p>
<p>Speichere einfach den FormatString als std::string in deiner Klasse, d.h. benutze nur lokal std::stringstream und weise dann mittels .str() den Inhalt der std::string Membervariablen zu.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1960226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1960226</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Fri, 01 Oct 2010 18:08:41 GMT</pubDate></item><item><title><![CDATA[Reply to Unverständlicher Templatefehler on Sat, 02 Oct 2010 01:25:28 GMT]]></title><description><![CDATA[<p>Icematix schrieb:</p>
<blockquote>
<p>Da der Compiler einen 'std::basic_stringstream&lt;_Elem,_Traits,_Alloc&gt;::basic_stringstream(const std::basic_stringstream&lt;_Elem,_Traits,_Alloc&gt; &amp;)' erzeugt, scheint ein stringstream im Gegensatz zu fstream etc kopierbar zu sein, oder irre ich mich da?</p>
</blockquote>
<p>Der erwähnte Kopierkonstruktor ist privat (und höchstwahrscheinlich nicht definiert) und daher nicht zugreifbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1960312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1960312</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sat, 02 Oct 2010 01:25:28 GMT</pubDate></item><item><title><![CDATA[Reply to Unverständlicher Templatefehler on Sat, 02 Oct 2010 07:00:19 GMT]]></title><description><![CDATA[<p>krümelkacker schrieb:</p>
<blockquote>
<p>Ausnahme-Objekte müssen kopierbar sein. Daher kannst Du da keinen stream reinpacken.</p>
</blockquote>
<p>Mit einem stringstream sollte es aber klappen, wenn man Kopierkonstruktor/op= definiert und dort den string mit std::stringstream::str() setzt.<br />
Aber prinzipiell ist die Variante mit einem lokalen stringstream im Konstruktor hier die bessere Variante.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1960333</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1960333</guid><dc:creator><![CDATA[mensameister]]></dc:creator><pubDate>Sat, 02 Oct 2010 07:00:19 GMT</pubDate></item><item><title><![CDATA[Reply to Unverständlicher Templatefehler on Sat, 02 Oct 2010 08:41:15 GMT]]></title><description><![CDATA[<blockquote>
<p>Der erwähnte Kopierkonstruktor ist privat (und höchstwahrscheinlich nicht definiert) und daher nicht zugreifbar.</p>
</blockquote>
<p>Aber ist ein compilergenerierter Kopierkonstruktor nicht automatisch public?</p>
<pre><code class="language-cpp">class Foo
{
private:
  Foo(const Foo&amp;);
}
</code></pre>
<p>wäre ja explizit nicht kopierbar.</p>
<p>Das Problem lag doch eher daran, dass der wohldefinierte und auch öffentliche Kopierkonstruktor versucht hat nichtkopierbare Membervariablen zu kopieren.</p>
<p>Aber danke, jetzt passts <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/1960347</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1960347</guid><dc:creator><![CDATA[Icematix]]></dc:creator><pubDate>Sat, 02 Oct 2010 08:41:15 GMT</pubDate></item></channel></rss>