Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/iterator/test/pointee.cpp @ 33

Last change on this file since 33 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.4 KB
Line 
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
38BOOST_TT_BROKEN_COMPILER_SPEC(X)
39   
40int main()
41{
42    STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<int> >::type, int);
43    STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<X> >::type, X);
44
45    STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<int const> >::type, int const);
46    STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<X const> >::type, X const);
47   
48    STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<int> >::type, int const);
49    STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<X> >::type, X const);
50   
51    STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<int const> >::type, int const);
52    STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<X const> >::type, X const);
53
54    STATIC_ASSERT_SAME(boost::pointee<int*>::type, int);
55    STATIC_ASSERT_SAME(boost::pointee<int const*>::type, int const);
56   
57    STATIC_ASSERT_SAME(boost::pointee<X*>::type, X);
58    STATIC_ASSERT_SAME(boost::pointee<X const*>::type, X const);
59
60    STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<int> >::type, int);
61    STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<X> >::type, X);
62   
63    STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<int const> >::type, int const);
64    STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<X const> >::type, X const);
65
66    STATIC_ASSERT_SAME(boost::pointee<std::list<int>::iterator >::type, int);
67    STATIC_ASSERT_SAME(boost::pointee<std::list<X>::iterator >::type, X);
68   
69    STATIC_ASSERT_SAME(boost::pointee<std::list<int>::const_iterator >::type, int const);
70    STATIC_ASSERT_SAME(boost::pointee<std::list<X>::const_iterator >::type, X const);
71    return 0;
72}
Note: See TracBrowser for help on using the repository browser.