]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/iterator/test/pointee.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / iterator / test / pointee.cpp
CommitLineData
7c673cae
FG
1// Copyright David Abrahams 2004. Use, modification and distribution is
2// subject to the Boost Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5#include <boost/pointee.hpp>
6#include <boost/type_traits/add_const.hpp>
7#include "static_assert_same.hpp"
8#include <memory>
9#include <list>
10
11template <class T, class Ref>
12struct proxy_ptr
13{
14 typedef T element_type;
15 struct proxy
16 {
17 operator Ref() const;
18 };
19 proxy operator*() const;
20};
21
22template <class T>
23struct proxy_ref_ptr : proxy_ptr<T,T&>
24{
25};
26
27template <class T>
28struct proxy_value_ptr : proxy_ptr<T,T>
29{
30 typedef typename boost::add_const<T>::type element_type;
31};
32
33struct X {
34 template <class T> X(T const&);
35 template <class T> operator T&() const;
36};
37
38
39int main()
40{
41 STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<int> >::type, int);
42 STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<X> >::type, X);
43
44 STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<int const> >::type, int const);
45 STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<X const> >::type, X const);
46
47 STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<int> >::type, int const);
48 STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<X> >::type, X const);
49
50 STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<int const> >::type, int const);
51 STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<X const> >::type, X const);
52
53 STATIC_ASSERT_SAME(boost::pointee<int*>::type, int);
54 STATIC_ASSERT_SAME(boost::pointee<int const*>::type, int const);
55
56 STATIC_ASSERT_SAME(boost::pointee<X*>::type, X);
57 STATIC_ASSERT_SAME(boost::pointee<X const*>::type, X const);
58
b32b8144
FG
59#if defined(BOOST_NO_CXX11_SMART_PTR)
60
7c673cae
FG
61 STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<int> >::type, int);
62 STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<X> >::type, X);
63
64 STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<int const> >::type, int const);
65 STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<X const> >::type, X const);
66
b32b8144
FG
67#else
68
69 STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<int> >::type, int);
70 STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<X> >::type, X);
71
72 STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<int const> >::type, int const);
73 STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<X const> >::type, X const);
74
75#endif
76
7c673cae
FG
77 STATIC_ASSERT_SAME(boost::pointee<std::list<int>::iterator >::type, int);
78 STATIC_ASSERT_SAME(boost::pointee<std::list<X>::iterator >::type, X);
79
80 STATIC_ASSERT_SAME(boost::pointee<std::list<int>::const_iterator >::type, int const);
81 STATIC_ASSERT_SAME(boost::pointee<std::list<X>::const_iterator >::type, X const);
82 return 0;
83}