Created
August 25, 2011 03:42
-
-
Save aont/1169930 to your computer and use it in GitHub Desktop.
double value template
This file contains hidden or 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
| #include <iostream> | |
| using std::size_t; | |
| template<typename _base, size_t _index> | |
| class pow_i | |
| { | |
| public: | |
| const static double value = pow_i<_base, _index-1 >::value * _base::value; | |
| }; | |
| template<typename _base> | |
| class pow_i<_base, 0> | |
| { | |
| public: | |
| const static double value = 1; | |
| }; | |
| class ten | |
| { | |
| public: | |
| const static double value = 10; | |
| }; | |
| int main() | |
| { | |
| std::cout << pow_i<ten, 5>::value << std::endl; | |
| return 0; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment