deduced_dependent_predicate.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // Copyright Daniel Wallin 2006.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <boost/parameter/config.hpp>
  6. #include <boost/parameter/parameters.hpp>
  7. #include <boost/parameter/name.hpp>
  8. #include <boost/parameter/binding.hpp>
  9. #include "deduced.hpp"
  10. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  11. #include <boost/mp11/bind.hpp>
  12. #include <boost/mp11/utility.hpp>
  13. #include <type_traits>
  14. #else
  15. #include <boost/mpl/bool.hpp>
  16. #include <boost/mpl/placeholders.hpp>
  17. #include <boost/mpl/if.hpp>
  18. #include <boost/type_traits/is_same.hpp>
  19. #include <boost/type_traits/is_convertible.hpp>
  20. #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  21. #include <boost/type_traits/remove_reference.hpp>
  22. #else
  23. #include <boost/type_traits/add_lvalue_reference.hpp>
  24. #endif // Borland workarounds needed
  25. #endif // BOOST_PARAMETER_CAN_USE_MP11
  26. namespace test {
  27. BOOST_PARAMETER_NAME(x)
  28. BOOST_PARAMETER_NAME(y)
  29. BOOST_PARAMETER_NAME(z)
  30. } // namespace test
  31. #include <boost/core/lightweight_test.hpp>
  32. int main()
  33. {
  34. test::check<
  35. boost::parameter::parameters<
  36. test::tag::x
  37. , boost::parameter::optional<
  38. boost::parameter::deduced<test::tag::y>
  39. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  40. , boost::mp11::mp_bind<
  41. std::is_same
  42. , boost::mp11::_1
  43. , boost::mp11::mp_bind<
  44. test::tag::x::binding_fn
  45. , boost::mp11::_2
  46. >
  47. >
  48. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  49. , boost::mpl::if_<
  50. boost::is_same<
  51. #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  52. boost::mpl::_1
  53. , boost::remove_reference<
  54. boost::parameter::binding<
  55. boost::mpl::_2
  56. , test::tag::x
  57. >
  58. >
  59. #else
  60. boost::add_lvalue_reference<boost::mpl::_1>
  61. , boost::parameter::binding<boost::mpl::_2,test::tag::x>
  62. #endif // Borland workarounds needed
  63. >
  64. , boost::mpl::true_
  65. , boost::mpl::false_
  66. >
  67. #endif // BOOST_PARAMETER_CAN_USE_MP11
  68. >
  69. >
  70. >((test::_x = 0, test::_y = 1), 0, 1);
  71. test::check<
  72. boost::parameter::parameters<
  73. test::tag::x
  74. , boost::parameter::optional<
  75. boost::parameter::deduced<test::tag::y>
  76. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  77. , boost::mp11::mp_bind<
  78. std::is_same
  79. , boost::mp11::_1
  80. , boost::mp11::mp_bind<
  81. test::tag::x::binding_fn
  82. , boost::mp11::_2
  83. >
  84. >
  85. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  86. , boost::mpl::if_<
  87. boost::is_same<
  88. #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  89. boost::mpl::_1
  90. , boost::remove_reference<
  91. boost::parameter::binding<
  92. boost::mpl::_2
  93. , test::tag::x
  94. >
  95. >
  96. #else
  97. boost::add_lvalue_reference<boost::mpl::_1>
  98. , boost::parameter::binding<boost::mpl::_2,test::tag::x>
  99. #endif // Borland workarounds needed
  100. >
  101. , boost::mpl::true_
  102. , boost::mpl::false_
  103. >
  104. #endif // BOOST_PARAMETER_CAN_USE_MP11
  105. >
  106. >
  107. >((test::_x = 0U, test::_y = 1U), 0U, 1U);
  108. test::check<
  109. boost::parameter::parameters<
  110. test::tag::x
  111. , boost::parameter::optional<
  112. boost::parameter::deduced<test::tag::y>
  113. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  114. , boost::mp11::mp_bind<
  115. std::is_convertible
  116. , boost::mp11::_1
  117. , boost::mp11::mp_bind_q<test::tag::x,boost::mp11::_2>
  118. >
  119. #else
  120. , boost::mpl::if_<
  121. boost::is_convertible<boost::mpl::_1,test::tag::x::_>
  122. , boost::mpl::true_
  123. , boost::mpl::false_
  124. >
  125. #endif
  126. >
  127. >
  128. >((test::_x = 0, test::_y = 1), 0, 1);
  129. test::check<
  130. boost::parameter::parameters<
  131. test::tag::x
  132. , boost::parameter::optional<
  133. boost::parameter::deduced<test::tag::y>
  134. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  135. , boost::mp11::mp_bind<
  136. std::is_convertible
  137. , boost::mp11::_1
  138. , boost::mp11::mp_bind_q<test::tag::x,boost::mp11::_2>
  139. >
  140. #else
  141. , boost::mpl::if_<
  142. boost::is_convertible<boost::mpl::_1,test::tag::x::_1>
  143. , boost::mpl::true_
  144. , boost::mpl::false_
  145. >
  146. #endif
  147. >
  148. >
  149. >((test::_x = 0U, test::_y = 1U), 0U, 1U);
  150. return boost::report_errors();
  151. }