Subject: Re: [boost] constexpr, cmath functions and other functions and distributions
From: Christopher Kormanyos (e_float_at_[hidden])
Date: 2016-07-28 15:52:46
>> Is there any support for making std::abs and friends constexpr where>> possible in future versions of the C++ Standard?
> Here are the bad news: C++ committee wishes to keep it possible for the
> implementors of the Standard Library to reuse C headers.
Well, I was also thinking along these lines. I am not sure if the C++language requires constexpr versions of any mathematical functionsor if this is left as an implementation-specific artifact, or evenif it is specified as non-constexpr for C compatibility. In othercommunications, it has been mentioned that GCC providessome constexpr built-ins for certain <cmath> functions.But this might be an implementation-specific design choice,not a specification fulfillment.
> There is a small chance that a paper on making some of the C math> functions constexpr may be accepted if functions are trivial to> implement efficiently.
Basic functions such as absoulute value, sign manipulationas well as elementary transcendental functions such as trigonometricfunctions and power functions could readily be implemented asconstexpr. In my opinion, it depends on the direction of the C++language if these should actually be required in a constexpr form.
There is also a technical detal. Another Boost author reminded
that C++ can't overload on constexpr-ness. So there might bedifficulties with naming conventions for constexpr math functions.
Questions might arise like: Do you want sqrt(x) and alsoconstexpr_sqrt(x)? Do you need a <cmath> constexpr namespace?
Best regards, Chris
On Thursday, July 28, 2016 5:44 PM, Antony Polukhin <antoshkka_at_[hidden]> wrote:
2016-07-28 16:24 GMT+03:00 Paul A. Bristow <pbristow_at_[hidden]>:
> After much head scratching (and some head banging) - against a string of
> "Computer Says No" inscrutable diagnostic messages.
It often helps to debug the constexpr realted issue using Clang compiler.
Sometimes it may provide more diagnostics than GCC (but sometimes it
compiles code that GCC refuses).
> I believe that I have now produced a (partial) version of Boost.Math
> normal_distribution that can be a constexpr using GCC6.1.1.
That's very very very good. However see the bad news down below.
> Without most cmath functions it seems to me impossible to write any
> reasonable (so-called special or not) mathy function or
> distribution that can be constexpr.
> Is there any support for making std::abs and friends constexpr where
> possible in future versions of the C++ Standard?
Here are the bad news: C++ committee wishes to keep it possible for the
implementors of the Standard Library to reuse C headers.
I've tried to add constexpr to the <cstring> in
The committee sad 'No', so I've removed the changes to <cstring> and only
then the paper passed into C++Next.
There is a small chance that a paper on making some of the C math functions
constexpr may be accepted if functions are trivial to implement efficiently.
I can write such paper and represent in to the C++ committee, but I'll need
a lot of help with:
* writing a list of C functions that could be simply implemented from
scratch without affecting performance (functions that usually take 1-3
lines to implement).
* implementing each of those function using constexpr
At least users will have the constexpr implementation in Boost.Math if the
paper won't be accepted.
-- Best regards, Antony Polukhin _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk