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 template<class T>
22 struct E1 {
23     typedef bool element_type;
24 };
25 
26 template<class T1, class T2>
27 struct E2 {
28     typedef bool element_type;
29 };
30 
31 template<class T1, class T2, class T3>
32 struct E3 {
33     typedef bool element_type;
34 };
35 
36 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
37 template<class T, class... U>
38 struct P { };
39 
40 template<class T, class... U>
41 struct E {
42     typedef bool element_type;
43 };
44 #endif
45 
main()46 int main()
47 {
48     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
49         boost::pointer_traits<int*>::element_type>));
50     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
51         boost::pointer_traits<P1<int> >::element_type>));
52     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
53         boost::pointer_traits<P2<int, char> >::element_type>));
54     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
55         boost::pointer_traits<P3<int, char, char> >::element_type>));
56 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
57     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<int,
58         boost::pointer_traits<P<int, char, char, char> >::element_type>));
59 #endif
60     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
61         boost::pointer_traits<E1<int> >::element_type>));
62     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
63         boost::pointer_traits<E2<int, int> >::element_type>));
64     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
65         boost::pointer_traits<E3<int, int, int> >::element_type>));
66 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
67     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
68         boost::pointer_traits<E<int, int, int, int> >::element_type>));
69 #endif
70     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void,
71         boost::pointer_traits<void*>::element_type>));
72     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<void,
73         boost::pointer_traits<P1<void> >::element_type>));
74     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
75         boost::pointer_traits<E1<void> >::element_type>));
76     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int,
77         boost::pointer_traits<const int*>::element_type>));
78     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<const int,
79         boost::pointer_traits<P1<const int> >::element_type>));
80     BOOST_TEST_TRAIT_TRUE((boost::core::is_same<bool,
81         boost::pointer_traits<E1<const int> >::element_type>));
82     return boost::report_errors();
83 }
84