ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.05k stars 372 forks source link

Make strong typedefs able to be constexpr #838

Closed drewr95 closed 2 months ago

drewr95 commented 4 months ago

I noticed that the strong typedefs _ETLTYPEDEF doesn't use constexpr when I think it could. I think this could additionally be applied to the custom enum macro and user type macros as well.

Example:

ETL_TYPEDEF(float, seconds);
constexpr seconds duration{1.0F};

Trying to constexpr a strong typedef results in a compilation error:

error: constexpr variable cannot have non-literal type 'const seconds' (aka 'const type_def<seconds_tag, float>')

jwellbelove commented 2 months ago

Fixed 20.38.11