Created
April 25, 2018 16:07
-
-
Save chriscasola/10889c721415999e1ff9c7eaa03bbf94 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
template<unsigned n> class Fib { | |
public: | |
enum { | |
value_type = Fib<n-1>::value_type + Fib<n-2>::value_type | |
}; | |
}; | |
template <> class Fib<1> { | |
public: | |
enum { value_type = 1 }; | |
}; | |
template <> class Fib<0> { | |
public: | |
enum { value_type = 0 }; | |
}; | |
int main() { | |
std::cout << "Fib(10): " << Fib<10>::value_type << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment