/*============================================================================= Copyright (c) 2001-2007 Joel de Guzman 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 #include namespace test { struct x //: boost::noncopyable // test non-copyable (hold this by reference) { int m; }; struct xx { int m; }; } template void write_test(F f) { using boost::phoenix::arg_names::arg1; using boost::phoenix::bind; T x_; bind(&T::m, f(x_))() = 122; BOOST_TEST(x_.m == 122); bind(&T::m, arg1)(f(x_)) = 123; BOOST_TEST(x_.m == 123); } template void read_test(F f) { using boost::phoenix::arg_names::arg1; using boost::phoenix::bind; T x_; x_.m = 123; BOOST_TEST(bind(&T::m, f(x_))() == 123); BOOST_TEST(bind(&T::m, arg1)(f(x_)) == 123); } struct identity { template T& operator()(T& t) const { return t; } }; struct constify { template T const& operator()(T const& t) const { return t; } }; struct add_pointer { template T* /*const*/ operator()(T& t) const { return &t; } }; struct add_const_pointer { template const T* /*const*/ operator()(T const& t) const { return &t; } }; int main() { write_test(add_pointer()); write_test(add_pointer()); read_test(identity()); read_test(constify()); read_test(add_pointer()); read_test(add_const_pointer()); read_test(identity()); read_test(constify()); read_test(add_pointer()); read_test(add_const_pointer()); return boost::report_errors(); }