sabriallani / ticpp

Automatically exported from code.google.com/p/ticpp
0 stars 0 forks source link

iterator's ++/-- operators wrong return value. #15

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Consider this source code:

#include <iostream>
#include <string>

#define TIXML_USE_STL
#define TIXML_USE_TICPP
#include "ticpp/ticpp.h"

using namespace std;
using namespace ticpp;

int main()
{
    string xml = "<foo><child1/><child2/><child3/></foo>";
    Document doc;
    doc.Parse( xml );
    Element *root = doc.FirstChildElement();
    cout << "Root: " << root->Value() << endl;
    Iterator< Element > child;
    child = child.begin( root );
    cout << "First child: " << child->Value() << endl;
    cout << "Still first child: " << (child++)->Value() << endl;
    cout << "Second child: " << child->Value() << endl;
    cout << "Third child: " << (++child)->Value() << endl;
}

What is the expected output?

Root: foo
First child: child1
Still first child: child1
Second child: child2
Third child: child3

What do you see instead?

Root: foo
First child: child1
Still first child: child2
Second child: child2
Third child: child3

What version of the product are you using? On what operating system?

Revision 86, Ubuntu Linux, gcc version 4.1.3 20070929 (prerelease) (Ubuntu
4.1.2-16ubuntu2)

Please provide any additional information below.

Operator++(int) defined in ticpp.h line 1119 and operator--(int) defined on
line 1132 should be reimplemented to something like this:

Iterator operator++(int)
{
    Iterator tmp( this );
    ++(*this);
    return tmp;
}

Original issue reported on code.google.com by kaspr...@gmail.com on 19 Feb 2008 at 1:54

GoogleCodeExporter commented 8 years ago
looks like a bug to me.
I confess that I've never used the return value of those operators.
I'll look at it soon.

Original comment by rjmy...@gmail.com on 19 Feb 2008 at 3:41

GoogleCodeExporter commented 8 years ago
svn r95

Original comment by rjmy...@gmail.com on 18 Jul 2008 at 12:27