Article 6KA9Y constexpr and performance result

constexpr and performance result

by
Mac1ek
from LinuxQuestions.org on (#6KA9Y)
Hi Why constexpr in function giving extremely high performance when i compare to plain function ?

example:

Code:constexpr auto fib_constexpr(unsigned int n) -> unsigned int {
return (n <= 1) ? n : fib_constexpr(n - 1) + fib_constexpr(n - 2);
}

auto fib_normal(unsigned int n) -> unsigned int {
return (n <= 1) ? n : fib_normal(n - 1) + fib_normal(n - 2);
}this constexpr function giving whole different result in performance

Thank You for answer.
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments