macros.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright David Abrahams, Daniel Wallin 2003.
  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.hpp>
  6. #include <boost/parameter/macros.hpp>
  7. #include <boost/bind.hpp>
  8. #include "basics.hpp"
  9. namespace test {
  10. BOOST_PARAMETER_FUN(int, f, 2, 4, f_parameters)
  11. {
  12. p[test::_tester](
  13. p[test::_name]
  14. , p[test::_value || boost::bind(&test::value_default)]
  15. , p[test::_index | 999]
  16. );
  17. return 1;
  18. }
  19. BOOST_PARAMETER_NAME(foo)
  20. BOOST_PARAMETER_NAME(bar)
  21. struct baz_parameters
  22. : boost::parameter::parameters<
  23. boost::parameter::optional<test::tag::foo>
  24. , boost::parameter::optional<test::tag::bar>
  25. >
  26. {
  27. };
  28. BOOST_PARAMETER_FUN(int, baz, 0, 2, baz_parameters)
  29. {
  30. return 1;
  31. }
  32. } // namespace test
  33. #include <boost/ref.hpp>
  34. #include <boost/core/lightweight_test.hpp>
  35. #include <string>
  36. int main()
  37. {
  38. test::f(
  39. test::values(
  40. std::string("foo")
  41. , std::string("bar")
  42. , std::string("baz")
  43. )
  44. , std::string("foo")
  45. , std::string("bar")
  46. , std::string("baz")
  47. );
  48. BOOST_TEST_EQ(1, test::baz());
  49. int x = 56;
  50. test::f(
  51. test::values(std::string("foo"), 666.222, 56)
  52. , test::_index = boost::ref(x)
  53. , test::_name = std::string("foo")
  54. );
  55. return boost::report_errors();
  56. }