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
12struct X
13{
14};
15
16struct Y: public X
17{
18};
19
20void f1( boost::reference_wrapper<X> r, Y * p )
21{
22 BOOST_TEST_EQ( r.get_pointer(), p );
23}
24
25void f2( boost::reference_wrapper<int const> r, int * p )
26{
27 BOOST_TEST_EQ( r.get_pointer(), p );
28}
29
30int 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

source code of boost/libs/core/test/ref_conversion_test.cpp