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

Author Topic: make sf::Vector2/3<T> classes have constexpr constructors and functions  (Read 2955 times)

0 Members and 1 Guest are viewing this topic.

Xeverous

  • Newbie
  • *
  • Posts: 1
    • View Profile
Pretty much in the title

Currently such code does not compile:
constexpr sf::Vector2u tile_size{64, 64};

GCC 5.1 output: (-std=c++14)
In file included from ../src/Application.cpp:4:0:
../src/Global.h:25:40: error: the type 'const Vector2u {aka const sf::Vector2<unsigned int>}' of constexpr variable 'constants::tile_size' is not literal
 constexpr sf::Vector2u tile_size{64, 64};
                                        ^
In file included from D:\Files\C++\include/SFML/Graphics/Rect.hpp:31:0,
                 from D:\Files\C++\include/SFGUI/Widget.hpp:5,
                 from D:\Files\C++\include/SFGUI/Container.hpp:3,
                 from D:\Files\C++\include/SFGUI/Bin.hpp:3,
                 from D:\Files\C++\include/SFGUI/Alignment.hpp:3,
                 from D:\Files\C++\include/SFGUI/Widgets.hpp:7,
                 from ../src/UserInterface.h:5,
                 from ../src/Application.h:3,
                 from ../src/Application.cpp:3:
D:\Files\C++\include/SFML/System/Vector2.hpp:37:7: note: 'sf::Vector2<unsigned int>' is not literal because:
 class Vector2
       ^
D:\Files\C++\include/SFML/System/Vector2.hpp:37:7: note:   'sf::Vector2<unsigned int>' is not an aggregate, does not have a trivial default constructor, and has no constexpr constructor that is not a copy or move constructor

It would be a convenient feature, and it's probably easy to implement

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
constexpr was introduced in C++11. SFML 2 is C++98.

That said, I'm sure this has been discussed before and there's a likelihood of it making SFML version 3 when it will take on board (at least) C++11.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything