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