• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 Copyright 2017 Glen Joseph Fernandes
3 (glenjofe@gmail.com)
4 
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
7 */
8 #include <boost/core/pointer_traits.hpp>
9 #include <boost/core/is_same.hpp>
10 #include <boost/core/lightweight_test_trait.hpp>
11 
12 template<class T>
13 struct P1 { };
14 
15 template<class T1, class T2>
16 struct P2 { };
17 
18 template<class T1, class T2, class T3>
19 struct P3 { };
20 
21 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
22 template<class T>
23 struct E1 {
24     template<class U>
25     using rebind = E1<bool>;
26 };
27 
28 template<class T1, class T2>
29 struct E2 {
30     template<class U>
31     using rebind = E2<bool, T2>;
32 };
33 
34 template<class T1, class T2, class T3>
35 struct E3 {
36     template<class U>
37     using rebind = E3<bool, T2, T3>;
38 };
39 #endif
40 
41 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
42 template<class T, class... U>
43 struct P { };
44 
45 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
46 template<class T, class... U>
47 struct E {
48     template<class V>
49     using rebind = E<bool, U...>;
50 };
51 #endif
52 #endif
53 
54 struct R { };
55 
main()56 int main()
57 {
58     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<char*,
59         boost::pointer_traits<R*>::rebind_to<char>::type>));
60     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<char>,
61         boost::pointer_traits<P1<R> >::rebind_to<char>::type>));
62     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P2<char, R>,
63         boost::pointer_traits<P2<R, R> >::rebind_to<char>::type>));
64     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P3<char, R, R>,
65         boost::pointer_traits<P3<R, R, R> >::rebind_to<char>::type>));
66 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
67     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P<char, R, R, R>,
68         boost::pointer_traits<P<R, R, R, R> >::rebind_to<char>::type>));
69 #endif
70     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void*,
71         boost::pointer_traits<R*>::rebind_to<void>::type>));
72     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<void>,
73         boost::pointer_traits<P1<R> >::rebind_to<void>::type>));
74     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<R*,
75         boost::pointer_traits<void*>::rebind_to<R>::type>));
76     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<R>,
77         boost::pointer_traits<P1<void> >::rebind_to<R>::type>));
78     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int*,
79         boost::pointer_traits<R*>::rebind_to<const int>::type>));
80     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<const int>,
81         boost::pointer_traits<P1<R> >::rebind_to<const int>::type>));
82     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int*,
83         boost::pointer_traits<const R*>::rebind_to<int>::type>));
84     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<P1<int>,
85         boost::pointer_traits<P1<const R> >::rebind_to<int>::type>));
86 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
87     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
88         boost::pointer_traits<E1<R> >::rebind_to<char>::type>));
89     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E2<bool, R>,
90         boost::pointer_traits<E2<R, R> >::rebind_to<char>::type>));
91     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E3<bool, R, R>,
92         boost::pointer_traits<E3<R, R, R> >::rebind_to<char>::type>));
93 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
94     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E<bool, R, R, R>,
95         boost::pointer_traits<E<R, R, R, R> >::rebind_to<char>::type>));
96 #endif
97     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
98         boost::pointer_traits<E1<R> >::rebind_to<void>::type>));
99     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
100         boost::pointer_traits<E1<void> >::rebind_to<R>::type>));
101     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
102         boost::pointer_traits<E1<R> >::rebind_to<const int>::type>));
103     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<E1<bool>,
104         boost::pointer_traits<E1<const R> >::rebind_to<int>::type>));
105 #endif
106     return boost::report_errors();
107 }
108