Created
June 19, 2019 13:35
-
-
Save lukaskollmer/f853375b5fe2b0e3b31e5c7950c228c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run w/ `CXX -DX=VAL`, where VAL is the input value | |
// https://godbolt.org/z/KgRth3 | |
template <int N> | |
struct Fib { | |
enum { | |
value = Fib<N-1>::value + Fib<N-2>::value | |
}; | |
}; | |
template <> | |
struct Fib<0> { | |
enum { | |
value = 0 | |
}; | |
}; | |
template <> | |
struct Fib<1> { | |
enum { | |
value = 1 | |
}; | |
}; | |
int main() { | |
return Fib<X>::value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment