Advertisement
Guest User

Untitled

a guest
May 25th, 2012
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <typename T, int lhs_size, int rhs_size>
  5. array<T, lhs_size + rhs_size> concat(const array<T, lhs_size>& lhs, const array<T, rhs_size>& rhs){
  6.  
  7.   array<T, lhs_size + rhs_size> result;
  8.   // copy values from lhs and rhs to result
  9.   return result;
  10.  
  11. }
  12.  
  13. template< int n >
  14. struct factorial { enum { ret = factorial< n - 1 >::ret * n }; };
  15.  
  16. template<>
  17. struct factorial< 0 > { enum { ret = 1 }; };
  18.  
  19. int main() {
  20.     cout << "7! = " << factorial< 7 >::ret << endl; // 5040
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement