2

If found the following code snippet on cppreference:

inline constexpr std::size_t dynamic_extent = std::numeric_limits<std::size_t>::max();

I thought constepxr implies inline.

  • Is there any value in marking a variable as constexpr and inline?

I found different sources giving different answers. Some say yes. Others say no. I'm confused.

Does constexpr imply inline? does not clearly answers my question. Because the related answer saying no has a comment saying yes. I found other sources saying yes, too. But cppreference still uses both.

Martin Fehrs
  • 792
  • 4
  • 13
  • 1
    Hm the former question appears to ask about inline functions, whereas this is asking about variables. I agree also that the answer there which says "no" also has a comment saying "yes". Overall I left that question not actually knowing with 100% certainty. – Tas Jun 23 '20 at 21:44
  • " A constexpr specifier used in a function or static member variable (since C++17) declaration implies inline". So the answer is no. – Monster Hunter Dec 29 '20 at 20:22

0 Answers0