Pros of defining a function to be constexpr

Правка en1, от Qualified, 2020-07-07 22:27:44

What are the pros for defining a function to be constexpr. For example the gcd function

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

can be written using constexpr

constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

Is there any improvement in time it takes to run or execute the program or any other benefits?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Qualified 2020-07-07 22:27:44 416 Initial revision (published)