<?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[iterator temporaer problem ....]]></title><description><![CDATA[<p>Sorry, ich sehs momentan grad ned, gebt mir mal nen schlag aufn hinterkopf !</p>
<p>Ich will ne STL List Klasse kapseln, aber so das sie sich wie teilweise! ne ListKlasse verhaelt. Sprich, ich will etwas spezialisieren, und einige funktionalitaet abklemmen.</p>
<p>wichtig ist mir dabei, das ich STL like iterieren kann, also :</p>
<pre><code class="language-cpp">for(MyListCLass::const_iterator it = rList.begin(); (it != rList.end()); it++)
	{
		// Tu Was ... 
	}
</code></pre>
<p>Die klasse soll speziell fuer ne andere Klasse die Liste darstellen<br />
also definier ich die Listenklasse folgendermassen:</p>
<p>Mylistclass.h</p>
<pre><code class="language-cpp">class MyListCLass
{
private: 
	typedef std::list&lt;ListObject&gt; List_t;
public:
	typedef List_t::iterator iterator;
	typedef List_t::const_iterator const_iterator;

	MyListCLass();
	virtual ~MyListCLass();

	MyListCLass::iterator begin();
	MyListCLass::const_iterator begin() const;

	MyListCLass::iterator end();
	MyListCLass::const_iterator end() const;

	void insert (const ListObject &amp; rObject);

private:
	List_t m_List;

};
</code></pre>
<p>auszug aus Mylistclass.cpp</p>
<pre><code class="language-cpp">MyListCLass::iterator MyListCLass::begin()
{
	return m_List.begin();
}
MyListCLass::const_iterator MyListCLass::begin() const
{
	return m_List.begin();
}
MyListCLass::iterator MyListCLass::end()
{
	return m_List.end();
}
MyListCLass::const_iterator MyListCLass::end() const
{
	return m_List.end();
}
</code></pre>
<p>Und tatata, obrige schleife funktioniert nicht ....<br />
er erkennt den ende iterator nicht ...<br />
die iteratoren die er durchlaeuft sind ok, zeigen auch alle auf das richtige, vorher eingefuegte Object. Aber it != rList.end() trifft immer zu. beim debuggen zeigen die internen Iteratoren zeiger (_P) auch auf unterschiedliche Adressen ....<br />
Aber der end iterator muesste doch noch gueltig sein ? die liste wird zwischendurch ned angefasst ....</p>
<p>Ciao ...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/60840/iterator-temporaer-problem</link><generator>RSS for Node</generator><lastBuildDate>Sat, 02 May 2026 03:06:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/60840.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 09 Jan 2004 11:26:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to iterator temporaer problem .... on Fri, 09 Jan 2004 12:20:14 GMT]]></title><description><![CDATA[<p>Sorry, ich sehs momentan grad ned, gebt mir mal nen schlag aufn hinterkopf !</p>
<p>Ich will ne STL List Klasse kapseln, aber so das sie sich wie teilweise! ne ListKlasse verhaelt. Sprich, ich will etwas spezialisieren, und einige funktionalitaet abklemmen.</p>
<p>wichtig ist mir dabei, das ich STL like iterieren kann, also :</p>
<pre><code class="language-cpp">for(MyListCLass::const_iterator it = rList.begin(); (it != rList.end()); it++)
	{
		// Tu Was ... 
	}
</code></pre>
<p>Die klasse soll speziell fuer ne andere Klasse die Liste darstellen<br />
also definier ich die Listenklasse folgendermassen:</p>
<p>Mylistclass.h</p>
<pre><code class="language-cpp">class MyListCLass
{
private: 
	typedef std::list&lt;ListObject&gt; List_t;
public:
	typedef List_t::iterator iterator;
	typedef List_t::const_iterator const_iterator;

	MyListCLass();
	virtual ~MyListCLass();

	MyListCLass::iterator begin();
	MyListCLass::const_iterator begin() const;

	MyListCLass::iterator end();
	MyListCLass::const_iterator end() const;

	void insert (const ListObject &amp; rObject);

private:
	List_t m_List;

};
</code></pre>
<p>auszug aus Mylistclass.cpp</p>
<pre><code class="language-cpp">MyListCLass::iterator MyListCLass::begin()
{
	return m_List.begin();
}
MyListCLass::const_iterator MyListCLass::begin() const
{
	return m_List.begin();
}
MyListCLass::iterator MyListCLass::end()
{
	return m_List.end();
}
MyListCLass::const_iterator MyListCLass::end() const
{
	return m_List.end();
}
</code></pre>
<p>Und tatata, obrige schleife funktioniert nicht ....<br />
er erkennt den ende iterator nicht ...<br />
die iteratoren die er durchlaeuft sind ok, zeigen auch alle auf das richtige, vorher eingefuegte Object. Aber it != rList.end() trifft immer zu. beim debuggen zeigen die internen Iteratoren zeiger (_P) auch auf unterschiedliche Adressen ....<br />
Aber der end iterator muesste doch noch gueltig sein ? die liste wird zwischendurch ned angefasst ....</p>
<p>Ciao ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/432253</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/432253</guid><dc:creator><![CDATA[RHBaum]]></dc:creator><pubDate>Fri, 09 Jan 2004 12:20:14 GMT</pubDate></item><item><title><![CDATA[Reply to iterator temporaer problem .... on Fri, 09 Jan 2004 11:30:24 GMT]]></title><description><![CDATA[<p>RHBaum schrieb:</p>
<blockquote>
<pre><code class="language-cpp">class MyListCLass
{
private: 
	typedef std::list&lt;ListObject&gt; List_t;
public:
	typedef iterator List_t::iterator;
	typedef const_iterator List_t::const_iterator;
// [ SCHA-NIPP! ]
</code></pre>
</blockquote>
<p>Das compiliert? typedef kenn ich andersrum.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/432256</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/432256</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Fri, 09 Jan 2004 11:30:24 GMT</pubDate></item><item><title><![CDATA[Reply to iterator temporaer problem .... on Fri, 09 Jan 2004 12:31:24 GMT]]></title><description><![CDATA[<p>ups, sorry, berichtige :p</p>
<p>Passiert, wenn man ned richtig abschreibt !!!<br />
Klassennamen sind im Zuge des Personenschutzes geaendert ! :p<br />
Die Orginalfiles lassesn sich compilieren, da ist aber auch das typedef richtig rum ...</p>
<p>Ciao ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/432306</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/432306</guid><dc:creator><![CDATA[RHBaum]]></dc:creator><pubDate>Fri, 09 Jan 2004 12:31:24 GMT</pubDate></item><item><title><![CDATA[Reply to iterator temporaer problem .... on Fri, 09 Jan 2004 13:09:48 GMT]]></title><description><![CDATA[<p>Komisch, ich mach das aber auch immer so. Sicher, dass du nicht auch noch was anderes falsch (bzw. &quot;richtig&quot;) abgeschrieben hast?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/432354</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/432354</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Fri, 09 Jan 2004 13:09:48 GMT</pubDate></item><item><title><![CDATA[Reply to iterator temporaer problem .... on Fri, 09 Jan 2004 16:07:42 GMT]]></title><description><![CDATA[<p>ok, dann doch vielleicht mal die orginale, ich sag niemals nie ! :p<br />
Vielleicht siehst wo ich mich verschrieben hab ...</p>
<p>FileCopyDefList ist das was ned funzt</p>
<pre><code class="language-cpp">// FileCopyDef.h: Schnittstelle für die Klasse FileCopyDef.
//
//////////////////////////////////////////////////////////////////////

#ifndef __FILECOPYDEF_H_
#define __FILECOPYDEF_H_

#include &lt;string&gt;
#include &lt;list&gt;

class FileCopyDef  
{
public:
	// Konstruktion ! 
	FileCopyDef();
	FileCopyDef(const FileCopyDef &amp; rx);
	FileCopyDef(const std::string &amp; rFileName,const std::string &amp; rSourceDir,const std::string &amp; rDestDir,bool aSubDirDate);
	FileCopyDef(const char * aFileName,const char * aSourceDir,const char * aDestDir,bool aSubDirDate);
	// Destruktion
	virtual ~FileCopyDef();

	// Zuweisungen 
	const FileCopyDef &amp; operator = (const FileCopyDef &amp; rx);

	// und noch setter und getter .... 
	void set_FileName(const char * aValue);
	void set_SourceDir(const char * aValue);
	void set_DestDir(const char * aValue);

	void set_FileName(const std::string &amp; aValue);
	void set_SourceDir(const std::string &amp; aValue);
	void set_DestDir(const std::string &amp; aValue);

	void set_SubDirDate(bool aVlaue);

	const char * get_FileName() const;
	const char * get_SourceDir() const;
	const char * get_DestDir() const;
	bool get_SubDirDate() const;
	void correctStrings();

private:
	// zum bereinigen 
	void correctDirString(std::string &amp; rx);
	void correctFileString(std::string &amp; rx);

	std::string		m_strFileName;
	std::string		m_strSourceDir;
	std::string		m_strDestDir;
	bool			m_bSubDirDate;
};

class FileCopyDefList
{
private:
	typedef std::list&lt;FileCopyDef&gt; TList_;
public:
	typedef TList_::iterator iterator;
	typedef TList_::const_iterator const_iterator;
	typedef TList_::reverse_iterator reverse_iterator;
	typedef TList_::const_reverse_iterator const_reverse_iterator;

public:
	FileCopyDefList();
	FileCopyDefList(const FileCopyDefList &amp; rx);
	virtual ~FileCopyDefList();

	// zuweisung 
	FileCopyDefList &amp; operator = (const FileCopyDefList &amp; rx);
	// Iteratorfunktionen 
	iterator &amp; begin();
	const_iterator &amp; begin() const;

	iterator &amp; end();
	const_iterator &amp; end() const;

	reverse_iterator &amp; rbegin();
	const_reverse_iterator &amp; rbegin() const;

	reverse_iterator &amp; rend();
	const_reverse_iterator &amp; rend() const;

	// einfuegen 
	void push_back(const FileCopyDef &amp; rValue);
	void push_front(const FileCopyDef &amp; rValue);
	// loeschen
	void clear();
	// bereinigen der Strings 
	void correctStrings();
private:
	TList_ m_List;

};
#endif // !defined(__FILECOPYDEF_H_)
</code></pre>
<pre><code class="language-cpp">// FileCopyDef.cpp
// Implementation von FileCopyDef 
#include &quot;stdafx.h&quot;
#include &quot;FileCopyDef.h&quot; 
#pragma warning( disable : 4172 4786)

////////////////////////////////////////////////////////////////////////////////////////////
// FileCopyDef 
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
// Konstruktion 
////////////////////////////////////////////////////////////////////////////////////////////
FileCopyDef::FileCopyDef()
{
}
FileCopyDef::FileCopyDef(const FileCopyDef &amp; rx):
m_strFileName(rx.m_strFileName),
m_strDestDir(rx.m_strDestDir),
m_strSourceDir(rx.m_strSourceDir),
m_bSubDirDate(rx.m_bSubDirDate)
{
}
FileCopyDef::FileCopyDef(const std::string &amp; rFileName,const std::string &amp; rSourceDir,const std::string &amp; rDestDir,bool aSubDirDate):
m_strFileName(rFileName),
m_strDestDir(rDestDir),
m_strSourceDir(rSourceDir),
m_bSubDirDate(aSubDirDate)
{
}
FileCopyDef::FileCopyDef(const char * aFileName,const char * aSourceDir,const char * aDestDir,bool aSubDirDate):
m_strFileName(aFileName),
m_strDestDir(aDestDir),
m_strSourceDir(aSourceDir),
m_bSubDirDate(aSubDirDate)
{
}
////////////////////////////////////////////////////////////////////////////////////////////
// Destruktion 
////////////////////////////////////////////////////////////////////////////////////////////
FileCopyDef::~FileCopyDef()
{
}
////////////////////////////////////////////////////////////////////////////////////////////
// Zuweisung
////////////////////////////////////////////////////////////////////////////////////////////
const FileCopyDef &amp; FileCopyDef::operator = (const FileCopyDef &amp; rx)
{
	if(&amp;rx != this)
	{
		m_strDestDir = rx.m_strDestDir;
		m_strFileName = rx.m_strFileName;
		m_strSourceDir = rx.m_strSourceDir;
		m_bSubDirDate = rx.m_bSubDirDate;
	}
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////
// Getter / Setter 
////////////////////////////////////////////////////////////////////////////////////////////
void FileCopyDef::set_FileName(const char * aValue)
{
	m_strFileName = aValue;
}
void FileCopyDef::set_SourceDir(const char * aValue)
{
	m_strSourceDir = aValue;
}
void FileCopyDef::set_DestDir(const char * aValue)
{
	m_strDestDir = aValue;
}

void FileCopyDef::set_FileName(const std::string &amp; aValue)
{ 
	m_strFileName = aValue;
}
void FileCopyDef::set_SourceDir(const std::string &amp; aValue)
{
	m_strSourceDir = aValue;
}
void FileCopyDef::set_DestDir(const std::string &amp; aValue)
{
	m_strDestDir = aValue;
}
void FileCopyDef::set_SubDirDate(bool aValue)
{
	m_bSubDirDate = aValue;
}

const char * FileCopyDef::get_FileName() const
{
	return m_strFileName.c_str();
}
const char * FileCopyDef::get_SourceDir() const
{
	return m_strSourceDir.c_str();
}
const char * FileCopyDef::get_DestDir() const
{
	return m_strDestDir.c_str();
}
bool FileCopyDef::get_SubDirDate() const
{
	return m_bSubDirDate;
}
void FileCopyDef::correctStrings()
{
	correctDirString(m_strDestDir);
	correctDirString(m_strSourceDir);
	correctFileString(m_strFileName); 
}

void FileCopyDef::correctDirString(std::string &amp; rx)
{
	// die ersten slashes und backslashes abfangen .... 
	while((rx.size() &gt; 0)  &amp;&amp; ((rx[0] == '/') || (rx[0] == '\\')))
	{
		rx.erase(0,1);
	}
	// die letzten slashes und backslashes abfangen .... 
	while((rx.size() &gt; 0)  &amp;&amp; ((rx[rx.size() -1] == '/') || (rx[rx.size() -1] == '\\')))
	{
		rx.erase(rx.size() -1,1);
	}
}
void FileCopyDef::correctFileString(std::string &amp; rx)
{
	// die letzten slashes und backslashes abfangen .... 
	while((rx.size() &gt; 0)  &amp;&amp; ((rx[rx.size() -1] == '/') || (rx[rx.size() -1] == '\\')))
	{
		rx.erase(rx.size() -1,1);
	}
}

////////////////////////////////////////////////////////////////////////////////////////////
// FileCopyDef 
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
// Konstruktion / Destruktion
////////////////////////////////////////////////////////////////////////////////////////////
FileCopyDefList::FileCopyDefList()
{
}
FileCopyDefList::FileCopyDefList(const FileCopyDefList &amp; rx):
m_List(rx.m_List)
{
}
FileCopyDefList::~FileCopyDefList()
{
}
////////////////////////////////////////////////////////////////////////////////////////////
// Iteratorfunktionen 
////////////////////////////////////////////////////////////////////////////////////////////
FileCopyDefList::iterator &amp; FileCopyDefList::begin()
{
	return m_List.begin();
}
FileCopyDefList::const_iterator &amp; FileCopyDefList::begin() const
{
	return m_List.begin();
}

FileCopyDefList::iterator &amp; FileCopyDefList::end()
{
	return m_List.end();
}
FileCopyDefList::const_iterator &amp; FileCopyDefList::end() const
{
	return m_List.end();
}

FileCopyDefList::reverse_iterator &amp; FileCopyDefList::rbegin()
{
	return m_List.rbegin();
}
FileCopyDefList::const_reverse_iterator &amp; FileCopyDefList::rbegin() const
{
	return m_List.rbegin();
}

FileCopyDefList::reverse_iterator &amp; FileCopyDefList::rend()
{
	return m_List.rend();
}
FileCopyDefList::const_reverse_iterator &amp; FileCopyDefList::rend() const
{
	return m_List.rend();
}
////////////////////////////////////////////////////////////////////////////////////////////
// Zuweisung
////////////////////////////////////////////////////////////////////////////////////////////
FileCopyDefList &amp; FileCopyDefList::operator = (const FileCopyDefList &amp; rx)
{
	if(&amp;rx != this)
	{
		m_List = rx.m_List;
	}
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////
// Einfuegen 
////////////////////////////////////////////////////////////////////////////////////////////
void FileCopyDefList::push_back(const FileCopyDef &amp; rValue)
{
	m_List.push_back(rValue);
}
void FileCopyDefList::push_front(const FileCopyDef &amp; rValue)
{
	m_List.push_front(rValue);
}
////////////////////////////////////////////////////////////////////////////////////////////
// loeschen
////////////////////////////////////////////////////////////////////////////////////////////
void FileCopyDefList::clear()
{
	m_List.clear();
}
</code></pre>
<p>die schleife selber</p>
<pre><code class="language-cpp">//////////////////////////////////////////////////////////////////////
// kopieren
//////////////////////////////////////////////////////////////////////
int FileCopyMan::copyFiles(const FileCopyDefList &amp; rList)
{
	int ireturn = 0;
	for(FileCopyDefList::const_iterator it = rList.begin(); (it != rList.end()); it++)
	{
		FileCopyDefList::const_iterator itest = rList.end();
		// bool bTest = it != rList.end();
		if(copyFile(*it))
			ireturn ++;
	}
	return ireturn;
}
</code></pre>
<p>Die referenz scheint ok zu sein, laut debugger .... zeigt Liste als member correct an ...</p>
<p>Ciao ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/432540</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/432540</guid><dc:creator><![CDATA[RHBaum]]></dc:creator><pubDate>Fri, 09 Jan 2004 16:07:42 GMT</pubDate></item><item><title><![CDATA[Reply to iterator temporaer problem .... on Fri, 09 Jan 2004 16:14:16 GMT]]></title><description><![CDATA[<p>Du gibst die Iteratoren per Referenz zurück. Da die aber jeweils lokale temporäre Objekte sind, existieren sie nach der Rückkehr nicht mehr -&gt; rumms (leise).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/432547</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/432547</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Fri, 09 Jan 2004 16:14:16 GMT</pubDate></item><item><title><![CDATA[Reply to iterator temporaer problem .... on Fri, 09 Jan 2004 19:21:53 GMT]]></title><description><![CDATA[<p>klatsch ... omg, jetzt wo du es sagst.</p>
<p>danke dir !</p>
<p>Ciao ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/432685</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/432685</guid><dc:creator><![CDATA[RHBaum]]></dc:creator><pubDate>Fri, 09 Jan 2004 19:21:53 GMT</pubDate></item></channel></rss>