| 1 | // Implicit conversions between compatible reference wrappers |
|---|---|
| 2 | // |
| 3 | // Copyright 2020 Peter Dimov |
| 4 | // |
| 5 | // Distributed under the Boost Software License, Version 1.0. |
| 6 | // See accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt |
| 8 | |
| 9 | #include <boost/core/ref.hpp> |
| 10 | #include <boost/core/lightweight_test.hpp> |
| 11 | |
| 12 | struct X |
| 13 | { |
| 14 | }; |
| 15 | |
| 16 | struct Y: public X |
| 17 | { |
| 18 | }; |
| 19 | |
| 20 | void f1( boost::reference_wrapper<X> r, Y * p ) |
| 21 | { |
| 22 | BOOST_TEST_EQ( r.get_pointer(), p ); |
| 23 | } |
| 24 | |
| 25 | void f2( boost::reference_wrapper<int const> r, int * p ) |
| 26 | { |
| 27 | BOOST_TEST_EQ( r.get_pointer(), p ); |
| 28 | } |
| 29 | |
| 30 | int main() |
| 31 | { |
| 32 | Y y; |
| 33 | f1( r: boost::ref(t&: y), p: &y ); |
| 34 | |
| 35 | int i = 0; |
| 36 | f2( r: boost::ref(t&: i), p: &i ); |
| 37 | |
| 38 | return boost::report_errors(); |
| 39 | } |
| 40 |
