Chris@16
|
1 #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
|
Chris@16
|
2 #define BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
|
Chris@16
|
3
|
Chris@16
|
4 // MS compatible compilers support #pragma once
|
Chris@16
|
5
|
Chris@16
|
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
Chris@16
|
7 # pragma once
|
Chris@16
|
8 #endif
|
Chris@16
|
9
|
Chris@16
|
10 // detail/sp_convertible.hpp
|
Chris@16
|
11 //
|
Chris@16
|
12 // Copyright 2008 Peter Dimov
|
Chris@16
|
13 //
|
Chris@16
|
14 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
15 // See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
16 // http://www.boost.org/LICENSE_1_0.txt
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/config.hpp>
|
Chris@101
|
19 #include <cstddef>
|
Chris@16
|
20
|
Chris@16
|
21 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_NO_SFINAE )
|
Chris@16
|
22 # define BOOST_SP_NO_SP_CONVERTIBLE
|
Chris@16
|
23 #endif
|
Chris@16
|
24
|
Chris@16
|
25 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ < 303 )
|
Chris@16
|
26 # define BOOST_SP_NO_SP_CONVERTIBLE
|
Chris@16
|
27 #endif
|
Chris@16
|
28
|
Chris@16
|
29 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x630 )
|
Chris@16
|
30 # define BOOST_SP_NO_SP_CONVERTIBLE
|
Chris@16
|
31 #endif
|
Chris@16
|
32
|
Chris@16
|
33 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
|
Chris@16
|
34
|
Chris@16
|
35 namespace boost
|
Chris@16
|
36 {
|
Chris@16
|
37
|
Chris@16
|
38 namespace detail
|
Chris@16
|
39 {
|
Chris@16
|
40
|
Chris@16
|
41 template< class Y, class T > struct sp_convertible
|
Chris@16
|
42 {
|
Chris@16
|
43 typedef char (&yes) [1];
|
Chris@16
|
44 typedef char (&no) [2];
|
Chris@16
|
45
|
Chris@16
|
46 static yes f( T* );
|
Chris@16
|
47 static no f( ... );
|
Chris@16
|
48
|
Chris@16
|
49 enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
|
Chris@16
|
50 };
|
Chris@16
|
51
|
Chris@16
|
52 template< class Y, class T > struct sp_convertible< Y, T[] >
|
Chris@16
|
53 {
|
Chris@16
|
54 enum _vt { value = false };
|
Chris@16
|
55 };
|
Chris@16
|
56
|
Chris@16
|
57 template< class Y, class T > struct sp_convertible< Y[], T[] >
|
Chris@16
|
58 {
|
Chris@16
|
59 enum _vt { value = sp_convertible< Y[1], T[1] >::value };
|
Chris@16
|
60 };
|
Chris@16
|
61
|
Chris@16
|
62 template< class Y, std::size_t N, class T > struct sp_convertible< Y[N], T[] >
|
Chris@16
|
63 {
|
Chris@16
|
64 enum _vt { value = sp_convertible< Y[1], T[1] >::value };
|
Chris@16
|
65 };
|
Chris@16
|
66
|
Chris@16
|
67 struct sp_empty
|
Chris@16
|
68 {
|
Chris@16
|
69 };
|
Chris@16
|
70
|
Chris@16
|
71 template< bool > struct sp_enable_if_convertible_impl;
|
Chris@16
|
72
|
Chris@16
|
73 template<> struct sp_enable_if_convertible_impl<true>
|
Chris@16
|
74 {
|
Chris@16
|
75 typedef sp_empty type;
|
Chris@16
|
76 };
|
Chris@16
|
77
|
Chris@16
|
78 template<> struct sp_enable_if_convertible_impl<false>
|
Chris@16
|
79 {
|
Chris@16
|
80 };
|
Chris@16
|
81
|
Chris@16
|
82 template< class Y, class T > struct sp_enable_if_convertible: public sp_enable_if_convertible_impl< sp_convertible< Y, T >::value >
|
Chris@16
|
83 {
|
Chris@16
|
84 };
|
Chris@16
|
85
|
Chris@16
|
86 } // namespace detail
|
Chris@16
|
87
|
Chris@16
|
88 } // namespace boost
|
Chris@16
|
89
|
Chris@16
|
90 #endif // !defined( BOOST_SP_NO_SP_CONVERTIBLE )
|
Chris@16
|
91
|
Chris@16
|
92 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
|