Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:50:35

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 namespace boost
0022 {
0023 
0024 namespace detail
0025 {
0026 
0027 template< class Y, class T > struct sp_convertible
0028 {
0029     typedef char (&yes) [1];
0030     typedef char (&no)  [2];
0031 
0032     static yes f( T* );
0033     static no  f( ... );
0034 
0035     enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
0036 };
0037 
0038 template< class Y, class T > struct sp_convertible< Y, T[] >
0039 {
0040     enum _vt { value = false };
0041 };
0042 
0043 template< class Y, class T > struct sp_convertible< Y[], T[] >
0044 {
0045     enum _vt { value = sp_convertible< Y[1], T[1] >::value };
0046 };
0047 
0048 template< class Y, std::size_t N, class T > struct sp_convertible< Y[N], T[] >
0049 {
0050     enum _vt { value = sp_convertible< Y[1], T[1] >::value };
0051 };
0052 
0053 struct sp_empty
0054 {
0055 };
0056 
0057 template< bool > struct sp_enable_if_convertible_impl;
0058 
0059 template<> struct sp_enable_if_convertible_impl<true>
0060 {
0061     typedef sp_empty type;
0062 };
0063 
0064 template<> struct sp_enable_if_convertible_impl<false>
0065 {
0066 };
0067 
0068 template< class Y, class T > struct sp_enable_if_convertible: public sp_enable_if_convertible_impl< sp_convertible< Y, T >::value >
0069 {
0070 };
0071 
0072 } // namespace detail
0073 
0074 } // namespace boost
0075 
0076 #endif  // #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED