|
Boost : |
From: John Maddock (jz.maddock_at_[hidden])
Date: 2021-08-23 17:20:39
On 23/08/2021 00:36, Ivan Matek via Boost wrote:
> On Sun, Aug 22, 2021 at 10:29 PM Robert Ramey via Boost <
> boost_at_[hidden]> wrote:
>
>> Yes.... but the function should really return the same value in both
>> constexpr and runtime usage.
>>
>> LOL - for me, the whole point of this is to use a different value
>> depending on whether or not the value is known at compile time. Maybe
>> someone wants to opine on this.
>>
> I think it would help discussion if you or John could provide a complete
> use case when different result is desired for a function depending on if it
> is running at compile time or not?
I could be wrong, but I don't believe that that would be a valid use
case, like you, the intended usage is to optimize runtime and compile
time usage, ie:
constexpr int f(int i)
{
 if(std::is_constant_evaluated())
 {
      // constexpr friendly code here
 }
 else
 {
   // Maybe use a function that's super fast but not constexpr safe
 }
}
John.
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk