Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Image::Reset() private?  (Read 2891 times)

0 Members and 1 Guest are viewing this topic.

T.T.H.

  • Full Member
  • ***
  • Posts: 112
    • View Profile
sf::Image::Reset() private?
« on: February 11, 2010, 05:02:16 pm »
Is there any reason why sf::Image::Reset() is private?

I'd could make good use of it if it would be public and by having a (short) look at the code I did only see Reset() being called after an error.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Image::Reset() private?
« Reply #1 on: February 11, 2010, 05:10:46 pm »
Why would you want an empty, invalid instance of sf::Image?

Anyway, this solution should work too:
Code: [Select]
image = sf::Image();
Laurent Gomila - SFML developer

T.T.H.

  • Full Member
  • ***
  • Posts: 112
    • View Profile
sf::Image::Reset() private?
« Reply #2 on: February 12, 2010, 10:22:06 am »
Quote from: "Laurent"
Why would you want an empty, invalid instance of sf::Image?

Because I might want to free the dynamic memory of the image without destructing the image (class) itself as it might be part of some resource management structure which I don't want to change at that point.

Quote from: "Laurent"
Anyway, this solution should work too:
Code: [Select]
image = sf::Image();

Yeah, should work, but... ugh...

Wouldn't it be simpler to make Reset() public? Maybe you want to keep the public interface as small as possible so you can change the internals without breaking the interface, but in my opinion a reset function for images makes enough sense to have it in the public interface.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Image::Reset() private?
« Reply #3 on: February 12, 2010, 11:22:45 am »
A Reset() function in a class usually doesn't sound right. If you want an empty instance then create one with the default constructor, that looks much cleaner to me.

I should even use it in my implementation, and get rid of Reset().
Laurent Gomila - SFML developer