//////////////////////////////////////////////////////////////////////////// // lazy_templated_struct_tests.cpp // // lazy templated struct test to check this works everywhere. // //////////////////////////////////////////////////////////////////////////// /*============================================================================= Copyright (c) 2001-2007 Joel de Guzman Copyright (c) 2015 John Fletcher Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #include #include #include #include #include namespace example { namespace impl { // Example of templated struct. template struct what { typedef Result result_type; Result operator()(Result const & r) const { return r; } }; template struct what0 { typedef Result result_type; Result operator()() const { return Result(100); } }; } boost::function1 what_int = impl::what(); boost::function0 what0_int = impl::what0(); BOOST_PHOENIX_ADAPT_FUNCTION(int,what,what_int,1) BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY(int,what0,what0_int) } int main() { int a = 99; using boost::phoenix::arg_names::arg1; BOOST_TEST(example::what_int(a) == a); BOOST_TEST(example::what(a)() == a); BOOST_TEST(example::what(arg1)(a) == a); BOOST_TEST(example::what0_int() == 100); BOOST_TEST(example::what0()() == 100); return boost::report_errors(); }