Chris@16: #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED Chris@16: #define BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED Chris@16: Chris@16: // MS compatible compilers support #pragma once Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1020) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: // detail/sp_convertible.hpp Chris@16: // Chris@16: // Copyright 2008 Peter Dimov Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt Chris@16: Chris@16: #include Chris@101: #include Chris@16: Chris@16: #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_NO_SFINAE ) Chris@16: # define BOOST_SP_NO_SP_CONVERTIBLE Chris@16: #endif Chris@16: Chris@16: #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ < 303 ) Chris@16: # define BOOST_SP_NO_SP_CONVERTIBLE Chris@16: #endif Chris@16: Chris@16: #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x630 ) Chris@16: # define BOOST_SP_NO_SP_CONVERTIBLE Chris@16: #endif Chris@16: Chris@16: #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: Chris@16: namespace detail Chris@16: { Chris@16: Chris@16: template< class Y, class T > struct sp_convertible Chris@16: { Chris@16: typedef char (&yes) [1]; Chris@16: typedef char (&no) [2]; Chris@16: Chris@16: static yes f( T* ); Chris@16: static no f( ... ); Chris@16: Chris@16: enum _vt { value = sizeof( (f)( static_cast(0) ) ) == sizeof(yes) }; Chris@16: }; Chris@16: Chris@16: template< class Y, class T > struct sp_convertible< Y, T[] > Chris@16: { Chris@16: enum _vt { value = false }; Chris@16: }; Chris@16: Chris@16: template< class Y, class T > struct sp_convertible< Y[], T[] > Chris@16: { Chris@16: enum _vt { value = sp_convertible< Y[1], T[1] >::value }; Chris@16: }; Chris@16: Chris@16: template< class Y, std::size_t N, class T > struct sp_convertible< Y[N], T[] > Chris@16: { Chris@16: enum _vt { value = sp_convertible< Y[1], T[1] >::value }; Chris@16: }; Chris@16: Chris@16: struct sp_empty Chris@16: { Chris@16: }; Chris@16: Chris@16: template< bool > struct sp_enable_if_convertible_impl; Chris@16: Chris@16: template<> struct sp_enable_if_convertible_impl Chris@16: { Chris@16: typedef sp_empty type; Chris@16: }; Chris@16: Chris@16: template<> struct sp_enable_if_convertible_impl Chris@16: { Chris@16: }; Chris@16: Chris@16: template< class Y, class T > struct sp_enable_if_convertible: public sp_enable_if_convertible_impl< sp_convertible< Y, T >::value > Chris@16: { Chris@16: }; Chris@16: Chris@16: } // namespace detail Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #endif // !defined( BOOST_SP_NO_SP_CONVERTIBLE ) Chris@16: Chris@16: #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED