Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:42

0001 #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
0002 #define BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
0003 
0004 // MS compatible compilers support #pragma once
0005 
0006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0007 # pragma once
0008 #endif
0009 
0010 //  detail/sp_convertible.hpp
0011 //
0012 //  Copyright 2008 Peter Dimov
0013 //
0014 //  Distributed under the Boost Software License, Version 1.0.
0015 //  See accompanying file LICENSE_1_0.txt or copy at
0016 //  http://www.boost.org/LICENSE_1_0.txt
0017 
0018 #include <boost/config.hpp>
0019 #include <cstddef>
0020 
0021 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_NO_SFINAE )
0022 # define BOOST_SP_NO_SP_CONVERTIBLE
0023 #endif
0024 
0025 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ < 303 )
0026 # define BOOST_SP_NO_SP_CONVERTIBLE
0027 #endif
0028 
0029 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_BORLANDC ) && ( BOOST_BORLANDC < 0x630 )
0030 # define BOOST_SP_NO_SP_CONVERTIBLE
0031 #endif
0032 
0033 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
0034 
0035 namespace boost
0036 {
0037 
0038 namespace detail
0039 {
0040 
0041 template< class Y, class T > struct sp_convertible
0042 {
0043     typedef char (&yes) [1];
0044     typedef char (&no)  [2];
0045 
0046     static yes f( T* );
0047     static no  f( ... );
0048 
0049     enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
0050 };
0051 
0052 template< class Y, class T > struct sp_convertible< Y, T[] >
0053 {
0054     enum _vt { value = false };
0055 };
0056 
0057 template< class Y, class T > struct sp_convertible< Y[], T[] >
0058 {
0059     enum _vt { value = sp_convertible< Y[1], T[1] >::value };
0060 };
0061 
0062 template< class Y, std::size_t N, class T > struct sp_convertible< Y[N], T[] >
0063 {
0064     enum _vt { value = sp_convertible< Y[1], T[1] >::value };
0065 };
0066 
0067 struct sp_empty
0068 {
0069 };
0070 
0071 template< bool > struct sp_enable_if_convertible_impl;
0072 
0073 template<> struct sp_enable_if_convertible_impl<true>
0074 {
0075     typedef sp_empty type;
0076 };
0077 
0078 template<> struct sp_enable_if_convertible_impl<false>
0079 {
0080 };
0081 
0082 template< class Y, class T > struct sp_enable_if_convertible: public sp_enable_if_convertible_impl< sp_convertible< Y, T >::value >
0083 {
0084 };
0085 
0086 } // namespace detail
0087 
0088 } // namespace boost
0089 
0090 #endif // !defined( BOOST_SP_NO_SP_CONVERTIBLE )
0091 
0092 #endif  // #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED