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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Hydrogen

Pages: [1]
1
Feature requests / Re: Add constexpr to appropriate data types
« 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.

2
Feature requests / Add constexpr to appropriate data types
« 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.
    ...
}


3
This is a very old thread, but I wanted to second the suggestion of actually making this change to the inheritance hierarchy. Looking at the documentation, I notice that (a) the classes that inherit from both Drawable and Transformable are exactly Shape, Sprite, and Text, and (b) Shape, Sprite, and Text each inherit exclusively from Drawable and Transformable. Thus it seems clear to me that "Drawable and Transformable" semantically describes a third type, which is conspicuously missing from the hierarchy.

Yes, there are workarounds, and no, this change won't solve every problem, but I still think it would be useful for many common cases, with no tangible drawbacks.

Pages: [1]