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

Author Topic: Add public typedef to Vector2  (Read 2798 times)

0 Members and 1 Guest are viewing this topic.

Neil

  • Newbie
  • *
  • Posts: 27
    • View Profile
Add public typedef to Vector2
« on: December 29, 2014, 08:03:32 pm »
Hi

Could this be added to Vector2 type please?

typedef T type;

I have some general template code, but I'm stuck, because I cannot query the type contained in vector. I would like to do Vector2::type.

Thank you.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Add public typedef to Vector2
« Reply #1 on: December 29, 2014, 08:12:00 pm »
Why do you need to "query" that?

If you're in a general template code, you either should be able to assume a certain type or use the template type and since sf::Vector2 is a template as well, you could just do sf::Vector2<T>.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Add public typedef to Vector2
« Reply #2 on: December 29, 2014, 09:06:21 pm »
Do it yourself:

template <typename T>
struct TypeOfVector
{
};

template <typename T>
struct TypeOfVector<sf::Vector2<T>>
{
    typedef T type;
};
Laurent Gomila - SFML developer

 

anything