units icon indicating copy to clipboard operation
units copied to clipboard

Support for `constexpr` declaration of the Negative values with literals

Open jinay1991 opened this issue 3 years ago • 1 comments

It was often required to define certain constants statically and preferably as constexpr, although there are certain times, values may need to be -ve. This is already possible with full declaration of the unit, although does not support alongside the literals. Please see example below:

static constexpr units::angle::radian_t kAngularValue{-30.0_deg};  /// ERROR: Compiler will not find `constexpr`
                                                                   /// definition of the literal to convert deg to
                                                                   /// radian implicitly for negative numbers.

static constexpr units::angle::radian_t kAngularValue = units::angle::degree_t{-30.0};  /// WORKS FINE
static constexpr units::angle::radian_t kAngularValue{30.0_deg};                        /// WORKS FINE

I request the FIX or SUPPORT for such use-case.

Thanks in advance.

Library Version: v2.3.1 Compiler Used: GCC v12, Clang v12

jinay1991 avatar Sep 04 '22 06:09 jinay1991

supported in the 3.0 releases. Consider backporting to 2.3.

nholthaus avatar Sep 26 '22 13:09 nholthaus