deduced-parameters0.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #include <boost/parameter.hpp>
  2. BOOST_PARAMETER_NAME(name)
  3. BOOST_PARAMETER_NAME(func)
  4. BOOST_PARAMETER_NAME(docstring)
  5. BOOST_PARAMETER_NAME(keywords)
  6. BOOST_PARAMETER_NAME(policies)
  7. struct default_call_policies
  8. {
  9. };
  10. struct no_keywords
  11. {
  12. };
  13. struct keywords
  14. {
  15. };
  16. #include <boost/mpl/bool.hpp>
  17. template <typename T>
  18. struct is_keyword_expression
  19. : boost::mpl::false_
  20. {
  21. };
  22. template <>
  23. struct is_keyword_expression<keywords>
  24. : boost::mpl::true_
  25. {
  26. };
  27. default_call_policies some_policies;
  28. void f()
  29. {
  30. }
  31. #include <boost/mpl/placeholders.hpp>
  32. #include <boost/mpl/if.hpp>
  33. #include <boost/mpl/eval_if.hpp>
  34. #include <boost/type_traits/is_convertible.hpp>
  35. char const*& blank_char_ptr()
  36. {
  37. static char const* larr = "";
  38. return larr;
  39. }
  40. BOOST_PARAMETER_FUNCTION(
  41. (bool), def, tag,
  42. (required (name,(char const*)) (func,*) ) // nondeduced
  43. (deduced
  44. (optional
  45. (docstring, (char const*), blank_char_ptr())
  46. (keywords
  47. // see 5
  48. , *(is_keyword_expression<boost::mpl::_>)
  49. , no_keywords()
  50. )
  51. (policies
  52. , *(
  53. boost::mpl::eval_if<
  54. boost::is_convertible<boost::mpl::_,char const*>
  55. , boost::mpl::false_
  56. , boost::mpl::if_<
  57. // see 5
  58. is_keyword_expression<boost::mpl::_>
  59. , boost::mpl::false_
  60. , boost::mpl::true_
  61. >
  62. >
  63. )
  64. , default_call_policies()
  65. )
  66. )
  67. )
  68. )
  69. {
  70. return true;
  71. }
  72. #include <boost/core/lightweight_test.hpp>
  73. int main()
  74. {
  75. char const* f_name = "f";
  76. def(f_name, &f, some_policies, "Documentation for f");
  77. def(f_name, &f, "Documentation for f", some_policies);
  78. def(
  79. f_name
  80. , &f
  81. , _policies = some_policies
  82. , "Documentation for f"
  83. );
  84. return boost::report_errors();
  85. }