Chris@16
|
1 // (C) Copyright Thorsten Ottosen 2005
|
Chris@16
|
2 // (C) Copyright Howard Hinnant 2004
|
Chris@16
|
3 // (C) Copyright Jonathan Turkanis 2004
|
Chris@16
|
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
|
Chris@16
|
6
|
Chris@16
|
7 //
|
Chris@16
|
8 // Contains type traits machinery for incomplete arrays. MPL compatibility
|
Chris@16
|
9 // is included for completeness, but is not necessary for the current
|
Chris@16
|
10 // application.
|
Chris@16
|
11 //
|
Chris@16
|
12
|
Chris@16
|
13 #ifndef BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED
|
Chris@16
|
14 #define BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED
|
Chris@16
|
15
|
Chris@16
|
16 #include <boost/config.hpp> // BOOST_STATIC_CONSTANT.
|
Chris@16
|
17 #include <boost/mpl/aux_/lambda_support.hpp>
|
Chris@16
|
18 #include <boost/mpl/and.hpp>
|
Chris@16
|
19 #include <boost/mpl/bool.hpp>
|
Chris@16
|
20 #include <boost/mpl/identity.hpp>
|
Chris@16
|
21 #include <boost/mpl/if.hpp>
|
Chris@16
|
22 #include <boost/type_traits/is_array.hpp>
|
Chris@16
|
23 #include <boost/type_traits/is_convertible.hpp>
|
Chris@16
|
24 #include <boost/type_traits/is_same.hpp>
|
Chris@16
|
25 #include <boost/type_traits/remove_bounds.hpp>
|
Chris@16
|
26 #include <boost/type_traits/remove_cv.hpp>
|
Chris@16
|
27 #include <boost/utility/enable_if.hpp>
|
Chris@16
|
28
|
Chris@16
|
29 namespace boost { namespace ptr_container_detail { namespace move_ptrs {
|
Chris@16
|
30
|
Chris@16
|
31 // From Howard Hinnant.
|
Chris@16
|
32 template<typename T, typename U>
|
Chris@16
|
33 struct is_array_convertible {
|
Chris@16
|
34 typedef typename remove_bounds<T>::type t_element;
|
Chris@16
|
35 typedef typename remove_bounds<U>::type u_element;
|
Chris@16
|
36 typedef typename remove_cv<t_element>::type t_base;
|
Chris@16
|
37 typedef typename remove_cv<u_element>::type u_base;
|
Chris@16
|
38 typedef typename
|
Chris@16
|
39 mpl::and_<
|
Chris@16
|
40 is_array<T>,
|
Chris@16
|
41 is_array<U>,
|
Chris@16
|
42 is_same<t_base, u_base>,
|
Chris@16
|
43 is_convertible<t_element*, u_element*>
|
Chris@16
|
44 >::type type;
|
Chris@16
|
45 BOOST_STATIC_CONSTANT(bool, value = type::value);
|
Chris@16
|
46 BOOST_MPL_AUX_LAMBDA_SUPPORT(2, is_array_convertible, (T, U))
|
Chris@16
|
47 };
|
Chris@16
|
48
|
Chris@16
|
49 template<typename T, typename U>
|
Chris@16
|
50 struct is_smart_ptr_convertible
|
Chris@16
|
51 : mpl::if_<
|
Chris@16
|
52 is_array<T>,
|
Chris@16
|
53 is_array_convertible<T, U>,
|
Chris@16
|
54 is_convertible<T*, U*>
|
Chris@16
|
55 >::type
|
Chris@16
|
56 { };
|
Chris@16
|
57
|
Chris@16
|
58 #ifndef BOOST_NO_SFINAE
|
Chris@16
|
59 template<typename Src, typename Tgt, typename T = void>
|
Chris@16
|
60 struct enable_if_convertible
|
Chris@16
|
61 : enable_if<
|
Chris@16
|
62 is_smart_ptr_convertible<Src, Tgt>,
|
Chris@16
|
63 T
|
Chris@16
|
64 >
|
Chris@16
|
65 { };
|
Chris@16
|
66 #else
|
Chris@16
|
67 template<typename Src, typename Tgt, class T >
|
Chris@16
|
68 struct enable_if_convertible : mpl::identity<T> { };
|
Chris@16
|
69 #endif
|
Chris@16
|
70
|
Chris@16
|
71 } } } // End namespaces ptr_container_detail, move_ptrs, boost.
|
Chris@16
|
72
|
Chris@16
|
73 #endif // #ifndef BOOST_MOVE_PTR_ARRAYS_HPP_INCLUDED
|