1/*=============================================================================
2 Copyright (c) 2001-2007 Joel de Guzman
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6==============================================================================*/
7#include <string>
8#include <boost/detail/lightweight_test.hpp>
9#include <boost/phoenix/core.hpp>
10#include <boost/phoenix/object.hpp>
11
12using std::string;
13
14struct T
15{
16 string foo() { return "T"; }
17};
18
19struct U : T
20{
21 string foo() { return "U"; }
22};
23
24struct VT
25{
26 virtual string foo() { return "T"; }
27};
28
29struct VU : VT
30{
31 virtual string foo() { return "U"; }
32};
33
34int
35main()
36{
37 using boost::phoenix::arg_names::arg1;
38 using boost::phoenix::const_cast_;
39 using boost::phoenix::dynamic_cast_;
40 using boost::phoenix::reinterpret_cast_;
41 using boost::phoenix::static_cast_;
42
43 {
44 U u;
45 BOOST_TEST(arg1(u).foo() == "U");
46 BOOST_TEST(static_cast_<T&>(arg1)(u).foo() == "T");
47 }
48
49 {
50 U const u = U();
51 BOOST_TEST(const_cast_<U&>(arg1)(u).foo() == "U");
52 }
53
54 {
55 VU u;
56 VT* tp = &u;
57 BOOST_TEST(arg1(tp)->foo() == "U");
58 BOOST_TEST(dynamic_cast_<VU*>(arg1)(tp) != 0);
59 }
60
61 {
62 void* p = 0;
63 reinterpret_cast_<VU*>(u: arg1)(p); // compile test only
64 }
65
66 return boost::report_errors();
67}
68

source code of boost/libs/phoenix/test/object/cast_tests.cpp