1 #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
2 #define BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
10 // detail/sp_convertible.hpp
12 // Copyright 2008 Peter Dimov
14 // Distributed under the Boost Software License, Version 1.0.
15 // See accompanying file LICENSE_1_0.txt or copy at
16 // http://www.boost.org/LICENSE_1_0.txt
18 #include <boost/config.hpp>
21 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_NO_SFINAE )
22 # define BOOST_SP_NO_SP_CONVERTIBLE
25 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ < 303 )
26 # define BOOST_SP_NO_SP_CONVERTIBLE
29 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_BORLANDC ) && ( BOOST_BORLANDC < 0x630 )
30 # define BOOST_SP_NO_SP_CONVERTIBLE
33 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
41 template< class Y, class T > struct sp_convertible
43 typedef char (&yes) [1];
44 typedef char (&no) [2];
49 enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
52 template< class Y, class T > struct sp_convertible< Y, T[] >
54 enum _vt { value = false };
57 template< class Y, class T > struct sp_convertible< Y[], T[] >
59 enum _vt { value = sp_convertible< Y[1], T[1] >::value };
62 template< class Y, std::size_t N, class T > struct sp_convertible< Y[N], T[] >
64 enum _vt { value = sp_convertible< Y[1], T[1] >::value };
71 template< bool > struct sp_enable_if_convertible_impl;
73 template<> struct sp_enable_if_convertible_impl<true>
75 typedef sp_empty type;
78 template<> struct sp_enable_if_convertible_impl<false>
82 template< class Y, class T > struct sp_enable_if_convertible: public sp_enable_if_convertible_impl< sp_convertible< Y, T >::value >
90 #endif // !defined( BOOST_SP_NO_SP_CONVERTIBLE )
92 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED