1 | #include <boost/config.hpp> |
---|---|
2 | |
3 | // sp_convertible_test.cpp |
4 | // |
5 | // Copyright (c) 2008 Peter Dimov |
6 | // |
7 | // Distributed under the Boost Software License, Version 1.0. |
8 | // See accompanying file LICENSE_1_0.txt or copy at |
9 | // http://www.boost.org/LICENSE_1_0.txt |
10 | |
11 | #include <boost/core/lightweight_test.hpp> |
12 | #include <boost/shared_ptr.hpp> |
13 | |
14 | // |
15 | |
16 | class incomplete; |
17 | |
18 | struct X |
19 | { |
20 | }; |
21 | |
22 | struct Y |
23 | { |
24 | }; |
25 | |
26 | struct Z: public X |
27 | { |
28 | }; |
29 | |
30 | int f( boost::shared_ptr<void const> ) |
31 | { |
32 | return 1; |
33 | } |
34 | |
35 | int f( boost::shared_ptr<int> ) |
36 | { |
37 | return 2; |
38 | } |
39 | |
40 | int f( boost::shared_ptr<incomplete> ) |
41 | { |
42 | return 3; |
43 | } |
44 | |
45 | int g( boost::shared_ptr<X> ) |
46 | { |
47 | return 4; |
48 | } |
49 | |
50 | int g( boost::shared_ptr<Y> ) |
51 | { |
52 | return 5; |
53 | } |
54 | |
55 | int g( boost::shared_ptr<incomplete> ) |
56 | { |
57 | return 6; |
58 | } |
59 | |
60 | int main() |
61 | { |
62 | boost::shared_ptr<double> p1; |
63 | BOOST_TEST( 1 == f( p1 ) ); |
64 | BOOST_TEST( 1 == f( boost::shared_ptr<double>() ) ); |
65 | |
66 | boost::shared_ptr<Z> p2; |
67 | BOOST_TEST( 4 == g( p2 ) ); |
68 | BOOST_TEST( 4 == g( boost::shared_ptr<Z>() ) ); |
69 | |
70 | return boost::report_errors(); |
71 | } |
72 |