SFML community forums

General => Feature requests => Topic started by: Hydrogen on February 25, 2017, 03:00:59 am

Title: Add constexpr to appropriate data types
Post by: Hydrogen on February 25, 2017, 03:00:59 am
Many of the simple containers (such as vectors and rectangles) out to have constexpr constructors and arithmetic operators. This is both a matter of efficiency and convenience.

Example 1:
auto vector_sum = sf::Vector2f{1, 2} + sf::Vector2f{3, 4}; // Optimization: compute vector_sum at compile-time if operator + is constexpr.

Example 2:
struct Foo {
    static constexpr sf::Vector2f vector_constant{5, 6}; // Only possible if ctor is constexpr.
    ...
}

Title: Re: Add constexpr to appropriate data types
Post by: Laurent on February 25, 2017, 09:14:33 am
http://en.sfml-dev.org/forums/index.php?topic=21571.0
Title: Re: Add constexpr to appropriate data types
Post by: Hydrogen on February 26, 2017, 04:14:27 am
That's odd; I specifically searched for "constexpr" using the search tool before I posted. Nothing showed up.
Title: Re: Add constexpr to appropriate data types
Post by: Laurent on February 26, 2017, 08:46:01 am
It's not specifically about constexpr, but rather about supporting new C++ standards, so yes you may not find it by searching a specific language keyword.