fork download
  1. namespace Rose
  2. {
  3. template<typename T>
  4. struct RemoveReference
  5. {
  6. typedef T Type;
  7. };
  8.  
  9. template<typename T>
  10. struct RemoveReference<T &>
  11. {
  12. typedef T Type;
  13. };
  14.  
  15. template<typename... Elems>
  16. class Tuple;
  17.  
  18. template<typename First, typename... Elems>
  19. class Tuple<First, Elems...>
  20. {
  21. public:
  22. Tuple(First a, Elems... more)
  23. : More(more...), Element(a)
  24. {
  25. }
  26.  
  27. Tuple<First, Elems...> & operator=(const Tuple<typename RemoveReference<First>::Type,
  28. typename RemoveReference<Elems>::Type...> & rhs)
  29. {
  30. this->Element = rhs.Element;
  31. this->More = rhs.More;
  32.  
  33. return *this;
  34. }
  35.  
  36. private:
  37. Tuple<Elems...> More;
  38. First Element;
  39. };
  40.  
  41. template<typename Only>
  42. class Tuple<Only>
  43. {
  44. public:
  45. Tuple(Only a) : Element(a)
  46. {
  47. }
  48.  
  49. Tuple<Only> & operator=(const Tuple<typename RemoveReference<Only>::Type> & rhs)
  50. {
  51. this->Element = rhs.Element;
  52.  
  53. return *this;
  54. }
  55.  
  56. private:
  57. Only Element;
  58. };
  59. }
  60.  
  61. int main()
  62. {
  63. Rose::Tuple<int, float, int> t(1, 1.f, 2);
  64. }
Success #stdin #stdout 0s 2824KB
stdin
Standard input is empty
stdout

Standard output is empty