BOOST_NO_TYPEID support (#1108).

[SVN r38976]
This commit is contained in:
Peter Dimov
2007-08-26 20:34:40 +00:00
parent bca336bf35
commit e0ca42bb88
14 changed files with 111 additions and 30 deletions

View File

@@ -32,7 +32,6 @@
#include <memory> // std::auto_ptr
#include <functional> // std::less
#include <new> // std::bad_alloc
#include <typeinfo> // std::type_info in get_deleter
namespace boost
{
@@ -259,7 +258,7 @@ public:
return std::less<sp_counted_base *>()( a.pi_, b.pi_ );
}
void * get_deleter(std::type_info const & ti) const
void * get_deleter( sp_typeinfo const & ti ) const
{
return pi_? pi_->get_deleter( ti ): 0;
}

View File

@@ -24,7 +24,7 @@
// formulation
//
#include <typeinfo>
#include "sp_typeinfo.hpp"
namespace boost
{
@@ -123,7 +123,7 @@ public:
delete this;
}
virtual void * get_deleter( std::type_info const & ti ) = 0;
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{

View File

@@ -25,7 +25,7 @@
// formulation
//
#include <typeinfo>
#include "sp_typeinfo.hpp"
namespace boost
{
@@ -111,7 +111,7 @@ public:
delete this;
}
virtual void * get_deleter( std::type_info const & ti ) = 0;
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{

View File

@@ -16,7 +16,7 @@
// Lock-free algorithm by Alexander Terekhov
//
#include <typeinfo>
#include "sp_typeinfo.hpp"
namespace boost
{
@@ -110,7 +110,7 @@ public:
delete this;
}
virtual void * get_deleter( std::type_info const & ti ) = 0;
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{

View File

@@ -24,7 +24,7 @@
// formulation
//
#include <typeinfo>
#include "sp_typeinfo.hpp"
namespace boost
{
@@ -134,7 +134,7 @@ public:
delete this;
}
virtual void * get_deleter( std::type_info const & ti ) = 0;
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{

View File

@@ -19,7 +19,7 @@
//
// Thanks to Michael van der Westhuizen
#include <typeinfo>
#include "sp_typeinfo.hpp"
#include <inttypes.h> // int32_t
namespace boost
@@ -119,7 +119,7 @@ public:
delete this;
}
virtual void * get_deleter( std::type_info const & ti ) = 0;
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{

View File

@@ -24,7 +24,7 @@
// formulation
//
#include <typeinfo>
#include "sp_typeinfo.hpp"
namespace boost
{
@@ -126,7 +126,7 @@ public:
delete this;
}
virtual void * get_deleter( std::type_info const & ti ) = 0;
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{

View File

@@ -18,7 +18,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <typeinfo>
#include "sp_typeinfo.hpp"
namespace boost
{
@@ -58,7 +58,7 @@ public:
delete this;
}
virtual void * get_deleter( std::type_info const & ti ) = 0;
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{

View File

@@ -18,7 +18,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <typeinfo>
#include "sp_typeinfo.hpp"
#include <pthread.h>
namespace boost
@@ -69,7 +69,7 @@ public:
delete this;
}
virtual void * get_deleter( std::type_info const & ti ) = 0;
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{

View File

@@ -20,7 +20,7 @@
// formulation
//
#include <typeinfo>
#include "sp_typeinfo.hpp"
#include <atomic.h>
namespace boost
@@ -61,7 +61,7 @@ public:
delete this;
}
virtual void * get_deleter( std::type_info const & ti ) = 0;
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{

View File

@@ -15,7 +15,7 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <typeinfo>
#include "sp_typeinfo.hpp"
#include <limits.h>
namespace boost
@@ -104,7 +104,7 @@ public:
delete this;
}
virtual void * get_deleter( std::type_info const & ti ) = 0;
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{

View File

@@ -26,7 +26,7 @@
#include <boost/detail/interlocked.hpp>
#include <boost/detail/workaround.hpp>
#include <typeinfo>
#include "sp_typeinfo.hpp"
namespace boost
{
@@ -66,7 +66,7 @@ public:
delete this;
}
virtual void * get_deleter( std::type_info const & ti ) = 0;
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
void add_ref_copy()
{

View File

@@ -35,7 +35,6 @@
#include <memory> // std::allocator
#endif
#include <typeinfo> // std::type_info in get_deleter
#include <cstddef> // std::size_t
namespace boost
@@ -79,7 +78,7 @@ public:
boost::checked_delete( px_ );
}
virtual void * get_deleter( std::type_info const & )
virtual void * get_deleter( detail::sp_typeinfo const & )
{
return 0;
}
@@ -145,9 +144,9 @@ public:
del( ptr );
}
virtual void * get_deleter( std::type_info const & ti )
virtual void * get_deleter( detail::sp_typeinfo const & ti )
{
return ti == typeid(D)? &reinterpret_cast<char&>( del ): 0;
return ti == BOOST_SP_TYPEID(D)? &reinterpret_cast<char&>( del ): 0;
}
#if defined(BOOST_SP_USE_STD_ALLOCATOR)
@@ -215,9 +214,9 @@ public:
a2.deallocate( this, 1 );
}
virtual void * get_deleter( std::type_info const & ti )
virtual void * get_deleter( detail::sp_typeinfo const & ti )
{
return ti == typeid( D )? &reinterpret_cast<char&>( d_ ): 0;
return ti == BOOST_SP_TYPEID( D )? &reinterpret_cast<char&>( d_ ): 0;
}
};

View File

@@ -0,0 +1,83 @@
#ifndef BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED
#define BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// detail/sp_typeinfo.hpp
//
// Copyright 2007 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if defined( BOOST_NO_TYPEID )
namespace boost
{
namespace detail
{
typedef void* sp_typeinfo;
template<class T> struct sp_typeid_
{
static char v_;
};
template<class T> char sp_typeid_< T >::v_;
template<class T> struct sp_typeid_< T const >: sp_typeid_< T >
{
};
template<class T> struct sp_typeid_< T volatile >: sp_typeid_< T >
{
};
template<class T> struct sp_typeid_< T const volatile >: sp_typeid_< T >
{
};
} // namespace detail
} // namespace boost
#define BOOST_SP_TYPEID(T) (&boost::detail::sp_typeid_<T>::v_)
#else
#include <typeinfo>
namespace boost
{
namespace detail
{
#if defined( BOOST_NO_STD_TYPEINFO )
typedef ::type_info sp_typeinfo;
#else
typedef std::type_info sp_typeinfo;
#endif
} // namespace detail
} // namespace boost
#define BOOST_SP_TYPEID(T) typeid(T)
#endif
#endif // #ifndef BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED