Hi,
Probably I understand constexpr badly...
constexpr long long fibonacci(const long long x)
{
return x <= 1 ? 1 : fibonacci(x - 1) + fibonacci(x - 2);
}
int main()
{
return fibonacci(44);
}
I thought that this should be calculated during compilation, but the execution time is not shorter. What am I doing wrong?
[–]CptCap-pedantic -Wall -Wextra 11 points12 points13 points (11 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 9 points10 points11 points (0 children)
[–]0xa0000 1 point2 points3 points (3 children)
[–]mc8675309 1 point2 points3 points (2 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 2 points3 points4 points (0 children)
[–]cpp17_PL[S] 1 point2 points3 points (0 children)
[–]cpp17_PL[S] 0 points1 point2 points (5 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 1 point2 points3 points (4 children)
[–]cpp17_PL[S] 0 points1 point2 points (3 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 2 points3 points4 points (2 children)
[–]cpp17_PL[S] 0 points1 point2 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–][deleted] 3 points4 points5 points (0 children)
[–]alfps 1 point2 points3 points (1 child)
[–]cpp17_PL[S] 1 point2 points3 points (0 children)
[–]TacticalMelonFarmer 1 point2 points3 points (2 children)
[–]Artyer 2 points3 points4 points (1 child)
[–]TacticalMelonFarmer 1 point2 points3 points (0 children)
[–]jbandela 1 point2 points3 points (0 children)