if_else.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef IF_ELSE_DWA2002322_HPP
  6. # define IF_ELSE_DWA2002322_HPP
  7. # include <boost/config.hpp>
  8. namespace boost { namespace python { namespace detail {
  9. template <class T> struct elif_selected;
  10. template <class T>
  11. struct if_selected
  12. {
  13. template <bool b>
  14. struct elif : elif_selected<T>
  15. {
  16. };
  17. template <class U>
  18. struct else_
  19. {
  20. typedef T type;
  21. };
  22. };
  23. template <class T>
  24. struct elif_selected
  25. {
  26. # if !(defined(__MWERKS__) && __MWERKS__ <= 0x2407)
  27. template <class U> class then;
  28. # else
  29. template <class U>
  30. struct then : if_selected<T>
  31. {
  32. };
  33. # endif
  34. };
  35. # if !(defined(__MWERKS__) && __MWERKS__ <= 0x2407)
  36. template <class T>
  37. template <class U>
  38. class elif_selected<T>::then : public if_selected<T>
  39. {
  40. };
  41. # endif
  42. template <bool b> struct if_
  43. {
  44. template <class T>
  45. struct then : if_selected<T>
  46. {
  47. };
  48. };
  49. struct if_unselected
  50. {
  51. template <bool b> struct elif : if_<b>
  52. {
  53. };
  54. template <class U>
  55. struct else_
  56. {
  57. typedef U type;
  58. };
  59. };
  60. template <>
  61. struct if_<false>
  62. {
  63. template <class T>
  64. struct then : if_unselected
  65. {
  66. };
  67. };
  68. }}} // namespace boost::python::detail
  69. #endif // IF_ELSE_DWA2002322_HPP