Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A7-1-2: Is it really intented to mark also functions as constexpr?
#2
It’s not the intention of this rule to force constexpr to be added to all functions who’s return value can be evaluated at compile time.

The example  const std::int32_t threeSquare = Pow1(3);  should be shown as compliant, because Pow1 has to be evaluated at run-time as its not constexpr.

However,  const std::int32_t  fourSquare = Pow2(4);    would be non-compliant, as Pow2 is declared constexpr, and Pow2(4) can be evaluated at compile-time, so foursquare can be declared constexpr.
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Messages In This Thread
RE: A7-1-2: Is it really intented to mark also functions as constexpr? - by misra cpp - 27-10-2023, 03:41 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)