Tuple.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace regex
  7. {
  8. struct Nothing { };
  9. template<typename T0, typename T1, typename T2 = Nothing, typename T3 = Nothing>
  10. class Tuple
  11. {
  12. T0 first;
  13. T1 second;
  14. T2 third;
  15. T3 forth;
  16. public:
  17. Tuple(T0 first, T1 second)
  18. : first(first), second(second)
  19. {
  20. CompileAssert(sizeof(T2)==sizeof(Nothing));
  21. CompileAssert(sizeof(T3)==sizeof(Nothing));
  22. }
  23. Tuple(T0 first, T1 second, T2 third)
  24. : first(first), second(second), third(third)
  25. {
  26. CompileAssert(sizeof(T3)==sizeof(Nothing));
  27. }
  28. T0 First() const
  29. {
  30. return first;
  31. }
  32. T1 Second() const
  33. {
  34. return second;
  35. }
  36. T2 Third() const
  37. {
  38. CompileAssert(sizeof(T2)!=sizeof(Nothing));
  39. return third;
  40. }
  41. T3 Forth() const
  42. {
  43. CompileAssert(sizeof(T3)!=sizeof(Nothing));
  44. return forth;
  45. }
  46. };
  47. }