SDLPP: add != for vector, add << for vector

This commit is contained in:
zvon 2021-08-06 18:49:23 +02:00
parent b87318f44d
commit 4728056b76

View File

@ -2,6 +2,7 @@
#define SDLPP_HPP_VECTOR #define SDLPP_HPP_VECTOR
#include "sdlpp_common.hpp" #include "sdlpp_common.hpp"
#include <ostream>
namespace SDLPP { namespace SDLPP {
template < typename T > class SDLPPSCOPE Vec2D { template < typename T > class SDLPPSCOPE Vec2D {
@ -41,6 +42,12 @@ public:
bool operator==( const Vec2D &other ) { bool operator==( const Vec2D &other ) {
return other._x == _x && other._y == _y; return other._x == _x && other._y == _y;
} }
bool operator!=( const Vec2D &other ) {
return !( *this == other );
}
template < typename K >
friend std::ostream &operator<<( std::ostream &stream,
const Vec2D< K > &vec );
private: private:
T _x = 0.0; T _x = 0.0;
@ -54,6 +61,11 @@ template < typename T >
Vec2D< T > operator/( double divisor, const Vec2D< T > &vec ) { Vec2D< T > operator/( double divisor, const Vec2D< T > &vec ) {
return vec / divisor; return vec / divisor;
} }
template < typename T >
std::ostream &operator<<( std::ostream &stream, const Vec2D< T > &vec ) {
stream << '(' << vec._x << ", " << vec._y << ")";
return stream;
}
} // namespace SDLPP } // namespace SDLPP
#endif #endif