Page 1 of 1

[no bug, just not nice]Comparative Operations On Position2d

Posted: Tue Mar 18, 2014 5:22 am
by kklouzal
Hello, I'm not sure if this functionality is supposed to be present but it allowed me to do a comparison without compiler errors. Here is the problem, doing a comparison on irr::core::vector2d<irr::s32> weather it is < or > only compares the X value.
When doing the comparison:

Code: Select all

void Compare()
{
    irr::core::position2d<irr::s32> A(30, 50);
    irr::core::position2d<irr::s32> B(10, 60);
    
    if (A > B)
    {
        std::cout << "A > B" << std::endl;
    }
    else {
        std::cout << "A !> B" << std::endl;
    }
}
A.X is > B.X but A.Y !> B.Y but the output is that A > B

Re: Comparative Operations On Position2d

Posted: Tue Mar 18, 2014 8:40 am
by hendu
Vector comparison is not usually defined except as a boolean vector. Irr uses the operator for sorting, due to C++ requirements. So this is not a bug, please open-code such comparisons in your app.

Re: Comparative Operations On Position2d

Posted: Tue Mar 18, 2014 10:43 am
by CuteAlien
Yeah, that was badly solved (my fault at least partly). Not having those operators at all would have been better (that just needed a minor rewrite of sorting).