| 1 | // Copyright (C) 2011 Cromwell D. Enage
|
|---|
| 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 |
|
|---|
| 6 | #include <boost/tr1/type_traits.hpp>
|
|---|
| 7 | #include <boost/tr1/functional.hpp>
|
|---|
| 8 | #include <boost/mpl/placeholders.hpp>
|
|---|
| 9 | #include <boost/parameter.hpp>
|
|---|
| 10 | #include <boost/parameter/macros.hpp>
|
|---|
| 11 |
|
|---|
| 12 | #define BOOST_TEST_MAIN
|
|---|
| 13 | #include <boost/test/unit_test.hpp>
|
|---|
| 14 |
|
|---|
| 15 | namespace your_test {
|
|---|
| 16 | namespace keyword {
|
|---|
| 17 |
|
|---|
| 18 | BOOST_PARAMETER_NAME(function)
|
|---|
| 19 | BOOST_PARAMETER_NAME(thing1)
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | struct foo
|
|---|
| 23 | {
|
|---|
| 24 | boost::function<long(double)> f;
|
|---|
| 25 | long end;
|
|---|
| 26 |
|
|---|
| 27 | template <typename ArgumentPack>
|
|---|
| 28 | foo(ArgumentPack const& args)
|
|---|
| 29 | : f(args[keyword::_function])
|
|---|
| 30 | , end(f(args[keyword::_thing1 | -1.0]))
|
|---|
| 31 | {
|
|---|
| 32 | }
|
|---|
| 33 | };
|
|---|
| 34 |
|
|---|
| 35 | struct bar : foo
|
|---|
| 36 | {
|
|---|
| 37 | BOOST_PARAMETER_CONSTRUCTOR(
|
|---|
| 38 | bar, (foo), keyword::tag,
|
|---|
| 39 | (required
|
|---|
| 40 | (function, *)
|
|---|
| 41 | )
|
|---|
| 42 | (optional
|
|---|
| 43 | (thing1, *)
|
|---|
| 44 | )
|
|---|
| 45 | )
|
|---|
| 46 | };
|
|---|
| 47 |
|
|---|
| 48 | #ifndef __STATIC_FUNCTION__
|
|---|
| 49 | long baz(double whammy)
|
|---|
| 50 | {
|
|---|
| 51 | return 0.0 < whammy ? 42 : 69;
|
|---|
| 52 | }
|
|---|
| 53 | #endif
|
|---|
| 54 |
|
|---|
| 55 | struct program
|
|---|
| 56 | {
|
|---|
| 57 | #ifdef __STATIC_FUNCTION__
|
|---|
| 58 | static long baz(double whammy)
|
|---|
| 59 | {
|
|---|
| 60 | return 0.0 < whammy ? 42 : 69;
|
|---|
| 61 | }
|
|---|
| 62 | #endif
|
|---|
| 63 |
|
|---|
| 64 | program()
|
|---|
| 65 | {
|
|---|
| 66 | bar nun(baz, 4.0);
|
|---|
| 67 | BOOST_CHECK(nun.f == baz);
|
|---|
| 68 | BOOST_CHECK(nun.end == 42);
|
|---|
| 69 | }
|
|---|
| 70 | };
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | BOOST_AUTO_TEST_CASE(ctor_macro_fun_param)
|
|---|
| 74 | {
|
|---|
| 75 | your_test::program suxors;
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|