fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <int one, int two, int three>
  5. struct vector_c{
  6. enum{
  7. v1 = one,
  8. v2 = two,
  9. v3 = three,
  10. sum = one+two+three
  11. };
  12.  
  13. template <typename vector>
  14. struct sumVector{
  15. typedef vector_c<
  16. one+vector::v1,
  17. two+vector::v2,
  18. three+vector::v3
  19. > type;
  20. };
  21.  
  22. template <typename anotherVector>
  23. struct multiplyByVector{
  24. typedef vector_c<
  25. one*anotherVector::v1,
  26. two*anotherVector::v2,
  27. three*anotherVector::v3
  28. > type;
  29. };
  30. };
  31.  
  32.  
  33. int main() {
  34. int a = vector_c<1,2,3>::sumVector<vector_c<3,2,1> >::type::sum;
  35.  
  36. vector_c<3,2,1>::multiplyByVector<vector_c<2,3,1> >::type::sum ;
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 2680KB
stdin
Standard input is empty
stdout
Standard output is empty