blob: 6c8b6b16dfd8860f54b507ee69478aeffbb059fa [file] [log] [blame]
Jeff Thompson3d613fd2013-10-15 15:39:04 -07001#ifndef NDNBOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
2#define NDNBOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
Jeff Thompsonf7d49942013-08-01 16:47:40 -07003
4// MS compatible compilers support #pragma once
5
6#if defined(_MSC_VER) && (_MSC_VER >= 1020)
7# pragma once
8#endif
9
10// detail/sp_convertible.hpp
11//
12// Copyright 2008 Peter Dimov
13//
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
17
Jeff Thompson2277ce52013-08-01 17:34:11 -070018#include <ndnboost/config.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070019
Jeff Thompson3d613fd2013-10-15 15:39:04 -070020#if !defined( NDNBOOST_SP_NO_SP_CONVERTIBLE ) && defined( NDNBOOST_NO_SFINAE )
21# define NDNBOOST_SP_NO_SP_CONVERTIBLE
Jeff Thompsonf7d49942013-08-01 16:47:40 -070022#endif
23
Jeff Thompson3d613fd2013-10-15 15:39:04 -070024#if !defined( NDNBOOST_SP_NO_SP_CONVERTIBLE ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ < 303 )
25# define NDNBOOST_SP_NO_SP_CONVERTIBLE
Jeff Thompsonf7d49942013-08-01 16:47:40 -070026#endif
27
Jeff Thompson3d613fd2013-10-15 15:39:04 -070028#if !defined( NDNBOOST_SP_NO_SP_CONVERTIBLE ) && defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x630 )
29# define NDNBOOST_SP_NO_SP_CONVERTIBLE
Jeff Thompsonf7d49942013-08-01 16:47:40 -070030#endif
31
Jeff Thompson3d613fd2013-10-15 15:39:04 -070032#if !defined( NDNBOOST_SP_NO_SP_CONVERTIBLE )
Jeff Thompsonf7d49942013-08-01 16:47:40 -070033
34namespace ndnboost
35{
36
37namespace detail
38{
39
40template< class Y, class T > struct sp_convertible
41{
42 typedef char (&yes) [1];
43 typedef char (&no) [2];
44
45 static yes f( T* );
46 static no f( ... );
47
48 enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
49};
50
51template< class Y, class T > struct sp_convertible< Y, T[] >
52{
53 enum _vt { value = false };
54};
55
56template< class Y, class T > struct sp_convertible< Y[], T[] >
57{
58 enum _vt { value = sp_convertible< Y[1], T[1] >::value };
59};
60
61template< class Y, std::size_t N, class T > struct sp_convertible< Y[N], T[] >
62{
63 enum _vt { value = sp_convertible< Y[1], T[1] >::value };
64};
65
66struct sp_empty
67{
68};
69
70template< bool > struct sp_enable_if_convertible_impl;
71
72template<> struct sp_enable_if_convertible_impl<true>
73{
74 typedef sp_empty type;
75};
76
77template<> struct sp_enable_if_convertible_impl<false>
78{
79};
80
81template< class Y, class T > struct sp_enable_if_convertible: public sp_enable_if_convertible_impl< sp_convertible< Y, T >::value >
82{
83};
84
85} // namespace detail
86
87} // namespace ndnboost
88
Jeff Thompson3d613fd2013-10-15 15:39:04 -070089#endif // !defined( NDNBOOST_SP_NO_SP_CONVERTIBLE )
Jeff Thompsonf7d49942013-08-01 16:47:40 -070090
Jeff Thompson3d613fd2013-10-15 15:39:04 -070091#endif // #ifndef NDNBOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED