/Src/Dependencies/Boost/libs/parameter/test/deduced.cpp

http://hadesmem.googlecode.com/ · C++ · 114 lines · 83 code · 13 blank · 18 comment · 0 complexity · f893bda95c4424f6db97ea26795977be MD5 · raw file

  1. // Copyright Daniel Wallin 2006. Use, modification and distribution is
  2. // subject to the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #include <boost/parameter/parameters.hpp>
  5. #include <boost/parameter/name.hpp>
  6. #include <boost/parameter/binding.hpp>
  7. #include "deduced.hpp"
  8. namespace parameter = boost::parameter;
  9. namespace mpl = boost::mpl;
  10. BOOST_PARAMETER_NAME(x)
  11. BOOST_PARAMETER_NAME(y)
  12. BOOST_PARAMETER_NAME(z)
  13. int main()
  14. {
  15. using namespace parameter;
  16. check<
  17. parameters<
  18. tag::x
  19. , tag::y
  20. >
  21. >(
  22. (_x = 0, _y = 1)
  23. , 0
  24. , 1
  25. );
  26. check<
  27. parameters<
  28. tag::x
  29. , required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
  30. , optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
  31. >
  32. >(
  33. (_x = 0, _y = not_present, _z = "foo")
  34. , _x = 0
  35. , "foo"
  36. );
  37. check<
  38. parameters<
  39. tag::x
  40. , required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
  41. , optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
  42. >
  43. >(
  44. (_x = 0, _y = 1, _z = "foo")
  45. , 0
  46. , "foo"
  47. , 1
  48. );
  49. check<
  50. parameters<
  51. tag::x
  52. , required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
  53. , optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
  54. >
  55. >(
  56. (_x = 0, _y = 1, _z = "foo")
  57. , 0
  58. , 1
  59. , "foo"
  60. );
  61. check<
  62. parameters<
  63. tag::x
  64. , required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
  65. , optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
  66. >
  67. >(
  68. (_x = 0, _y = 1, _z = "foo")
  69. , 0
  70. , _y = 1
  71. , "foo"
  72. );
  73. check<
  74. parameters<
  75. tag::x
  76. , required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
  77. , optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
  78. >
  79. >(
  80. (_x = 0, _y = 1, _z = "foo")
  81. , _z = "foo"
  82. , _x = 0
  83. , 1
  84. );
  85. // Fails becasue of parameters.hpp:428
  86. /*
  87. check<
  88. parameters<
  89. tag::x
  90. , required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
  91. , optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
  92. >
  93. >(
  94. (_x = 0, _y = 1, _z = "foo")
  95. , _x = 0
  96. , (long*)0
  97. , 1
  98. );
  99. */
  100. return 0;
  101. };