namespaces3.cpp 575 B

12345678910111213141516171819202122232425262728293031
  1. #include <boost/parameter.hpp>
  2. #include <iostream>
  3. namespace lib {
  4. namespace keywords {
  5. BOOST_PARAMETER_NAME(name)
  6. BOOST_PARAMETER_NAME(index)
  7. }
  8. BOOST_PARAMETER_FUNCTION(
  9. (int), f, keywords::tag, (optional (name,*,"bob")(index,(int),1))
  10. )
  11. {
  12. std::cout << name << ":" << index << std::endl;
  13. return index;
  14. }
  15. }
  16. #include <boost/core/lightweight_test.hpp>
  17. using namespace lib::keywords;
  18. int main()
  19. {
  20. int x = lib::f(_name = "bob", _index = 2);
  21. BOOST_TEST_EQ(x, 2);
  22. return boost::report_errors();
  23. }