enable_if.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #ifndef BOOST_QVM_ENABLE_IF_HPP_INCLUDED
  2. #define BOOST_QVM_ENABLE_IF_HPP_INCLUDED
  3. /// Copyright (c) 2008-2021 Emil Dotchevski and Reverge Studios, Inc.
  4. /// Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. /// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. // Boost enable_if library
  7. // Copyright 2003 (c) The Trustees of Indiana University.
  8. // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
  9. // Jeremiah Willcock (jewillco at osl.iu.edu)
  10. // Andrew Lumsdaine (lums at osl.iu.edu)
  11. namespace boost { namespace qvm {
  12. template<typename T, typename R=void>
  13. struct enable_if_has_type
  14. {
  15. typedef R type;
  16. };
  17. template <bool B, class T = void>
  18. struct enable_if_c {
  19. typedef T type;
  20. };
  21. template <class T>
  22. struct enable_if_c<false, T> {};
  23. template <class Cond, class T = void>
  24. struct enable_if : public enable_if_c<Cond::value, T> {};
  25. template <bool B, class T>
  26. struct lazy_enable_if_c {
  27. typedef typename T::type type;
  28. };
  29. template <class T>
  30. struct lazy_enable_if_c<false, T> {};
  31. template <class Cond, class T>
  32. struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
  33. template <bool B, class T = void>
  34. struct disable_if_c {
  35. typedef T type;
  36. };
  37. template <class T>
  38. struct disable_if_c<true, T> {};
  39. template <class Cond, class T = void>
  40. struct disable_if : public disable_if_c<Cond::value, T> {};
  41. template <bool B, class T>
  42. struct lazy_disable_if_c {
  43. typedef typename T::type type;
  44. };
  45. template <class T>
  46. struct lazy_disable_if_c<true, T> {};
  47. template <class Cond, class T>
  48. struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
  49. ////////////////////////////////////////////////
  50. // The types below are a copy of the original types above, to workaround MSVC-12 bugs.
  51. template<typename T, typename R=void>
  52. struct enable_if_has_type2
  53. {
  54. typedef R type;
  55. };
  56. template <bool B, class T = void>
  57. struct enable_if_c2 {
  58. typedef T type;
  59. };
  60. template <class T>
  61. struct enable_if_c2<false, T> {};
  62. template <class Cond, class T = void>
  63. struct enable_if2 : public enable_if_c2<Cond::value, T> {};
  64. template <bool B, class T>
  65. struct lazy_enable_if_c2 {
  66. typedef typename T::type type;
  67. };
  68. template <class T>
  69. struct lazy_enable_if_c2<false, T> {};
  70. template <class Cond, class T>
  71. struct lazy_enable_if2 : public lazy_enable_if_c2<Cond::value, T> {};
  72. template <bool B, class T = void>
  73. struct disable_if_c2 {
  74. typedef T type;
  75. };
  76. template <class T>
  77. struct disable_if_c2<true, T> {};
  78. template <class Cond, class T = void>
  79. struct disable_if2 : public disable_if_c2<Cond::value, T> {};
  80. template <bool B, class T>
  81. struct lazy_disable_if_c2 {
  82. typedef typename T::type type;
  83. };
  84. template <class T>
  85. struct lazy_disable_if_c2<true, T> {};
  86. template <class Cond, class T>
  87. struct lazy_disable_if2 : public lazy_disable_if_c2<Cond::value, T> {};
  88. } }
  89. #endif