Opened 8 years ago

Last modified 5 years ago

#10089 new Feature Requests

constexpr support in units

Reported by: gonzalobg88@… Owned by: Jürgen Hunold
Milestone: To Be Determined Component: units
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

There is currently no support for using units and quantities within constexpr functions. Annotating the constructors and operators with BOOST_CONSTEXPR where possible should be enough to allow this.

I can provide a partial patch that enables constexpr support for the parts of the library that I'm using. Should I use trac or send a pull-request? The later is preferable for me.

Change History (7)

comment:1 by anonymous, 8 years ago

I've submitted a pull-request here: github.com/boostorg/units/pull/1

comment:2 by Jürgen Hunold, 8 years ago

Owner: changed from Matthias Schabel to Jürgen Hunold

comment:3 by lou_langholtz@…, 6 years ago

Boost 1.62.0 doesn't appear to support constexpr in the units library yet this request was opened 2 years ago. Why the delay in supporting constexpr in the units library? What can I do to help this along?

comment:4 by gonzalobg88@…, 6 years ago

This feature would be nice to have, but nobody has had time to do it "with Boost quality" yet.

I wrote a patch back then, but it was very rough, introduced some problems, and I didn't have time to work on it anymore.

You can check the pull-request on github, go through the comments/discussion, and try to improve it.

If you need help, I can give you feedback.

in reply to:  4 comment:5 by lou_langholtz@…, 6 years ago

Replying to gonzalobg88@…:

This feature would be nice to have, but nobody has had time to do it "with Boost quality" yet.

Does this assessment include the pull request by muggenhor on Aug 14? https://github.com/boostorg/units/pull/22

...You can check the pull-request on github, go through the comments/discussion, and try to improve it.

Thank you. Started looking on github and found muggenhor's request that I linked above. Looks like his pull request is open while yours got closed. There is no one assigned to muggenhor's request nor labels/milestone however.

comment:6 by anonymous, 6 years ago

I don't see any comments on the PR, what needs to be done to get it merged?

comment:7 by anonymous, 5 years ago

This would be really nice to have this. Without it, you can't specify array sizes based on math done with "units". ex, I can't do this:

constexpr quantity<time> secs_4 = 4*seconds; constexpr quantity<time> secs_2 = 2*seconds; constexpr int array_size = static_cast<int>(secs_4/secs_2); int an_array[array_size];

I also converting everything to "static const" instead of constexpr, but that didn't work either.

Note: See TracTickets for help on using tickets.