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