SFML community forums

Help => System => Topic started by: Mr_Blame on June 19, 2016, 02:07:30 pm

Title: some arithmetic operations of sf::vector missing?
Post by: Mr_Blame on June 19, 2016, 02:07:30 pm
Hi!

After some SFML usage I noticed that I can compile this:
sf::Vector2f(4, 4) + sf::Vector2f(2, 2)
but I can't compile this:
sf::Vector2f(4, 4) / sf::Vector2f(2, 2) //i get some errors here saying that operator "/" is not overloaded

The question is simple: how can I correct it or is it a feature?
 
P.S

my IDE is Visual Studio 2015
Title: Re: some arithmetic operations of sf::vector missing?
Post by: victorlevasseur on June 19, 2016, 02:34:57 pm
Hi,

Dividing a vector by another one doesn't make sense. That's probably why it's not implemented (as well as the multiplication of two vectors)
Title: Re: some arithmetic operations of sf::vector missing?
Post by: Mr_Blame on June 19, 2016, 02:58:49 pm
Oh yeah, now I see it dividing is allowed only by using scalar types!
Thanks!
Title: Re: some arithmetic operations of sf::vector missing?
Post by: Hiura on June 19, 2016, 10:18:37 pm
You might want to look at `std::valarray` or similar, depending on what you want to do.