mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-05 15:54:39 +02:00
more has_rebind fixes
[SVN r16302]
This commit is contained in:
@@ -17,122 +17,25 @@
|
|||||||
#ifndef BOOST_MPL_AUX_HAS_REBIND_HPP_INCLUDED
|
#ifndef BOOST_MPL_AUX_HAS_REBIND_HPP_INCLUDED
|
||||||
#define BOOST_MPL_AUX_HAS_REBIND_HPP_INCLUDED
|
#define BOOST_MPL_AUX_HAS_REBIND_HPP_INCLUDED
|
||||||
|
|
||||||
#include "boost/mpl/aux_/type_wrapper.hpp"
|
#include "boost/mpl/aux_/has_xxx.hpp"
|
||||||
#include "boost/mpl/aux_/yes_no.hpp"
|
#include "boost/mpl/if.hpp"
|
||||||
#include "boost/mpl/aux_/config/msvc_typename.hpp"
|
#include "boost/mpl/bool_c.hpp"
|
||||||
#include "boost/mpl/aux_/config/overload_resolution.hpp"
|
#include "boost/type_traits/is_class.hpp"
|
||||||
#include "boost/config.hpp"
|
|
||||||
|
|
||||||
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
|
namespace boost { namespace mpl { namespace aux {
|
||||||
# include "boost/type_traits/is_reference.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost {
|
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_rebind_impl, rebind)
|
||||||
namespace mpl {
|
|
||||||
namespace aux {
|
|
||||||
|
|
||||||
#if !defined(BOOST_MPL_BROKEN_OVERLOAD_RESOLUTION)
|
|
||||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
|
||||||
|
|
||||||
// the implementation below is based on a USENET newsgroup's posting by
|
|
||||||
// Rani Sharoni (comp.lang.c++.moderated, 2002-03-17 07:45:09 PST)
|
|
||||||
|
|
||||||
template< typename T >
|
|
||||||
yes_tag
|
|
||||||
has_rebind_helper(type_wrapper<T>*, BOOST_MSVC_TYPENAME T::rebind*);
|
|
||||||
|
|
||||||
template< typename T >
|
|
||||||
no_tag
|
|
||||||
has_rebind_helper(type_wrapper<T>*, ...);
|
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
struct has_rebind
|
struct has_rebind
|
||||||
{
|
: if_c<
|
||||||
BOOST_STATIC_CONSTANT(bool, value =
|
::boost::is_class<T>::value
|
||||||
sizeof(has_rebind_helper((type_wrapper<T>*)0, 0))
|
, has_rebind_impl<T>
|
||||||
== sizeof(yes_tag)
|
, bool_c<false>
|
||||||
);
|
>::type
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// agurt, 11/sep/02: MSVC version, based on a USENET newsgroup's posting by
|
|
||||||
// John Madsen (comp.lang.c++.moderated, 1999-11-12 19:17:06 GMT);
|
|
||||||
// note that the code is _not_ standard-conforming, but it works,
|
|
||||||
// and it resolves some nasty ICE cases with the above implementation
|
|
||||||
|
|
||||||
template < bool ref = true >
|
|
||||||
struct has_rebind_impl
|
|
||||||
{
|
|
||||||
template < typename T > struct apply
|
|
||||||
{
|
|
||||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct has_rebind_impl< false >
|
|
||||||
{
|
|
||||||
template < typename T, typename rebind = int >
|
|
||||||
struct apply : T
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
static no_tag test(int*);
|
|
||||||
static yes_tag test(...);
|
|
||||||
|
|
||||||
public:
|
|
||||||
BOOST_STATIC_CONSTANT(
|
|
||||||
bool, value = sizeof(test(static_cast<rebind*>(0))) != sizeof(no_tag)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
struct has_rebind
|
|
||||||
: has_rebind_impl<boost::detail::is_reference_impl<T>::value>::template apply<T>
|
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
# define AUX_HAS_REBIND_SPEC(T) \
|
}}}
|
||||||
template<> struct has_rebind<T> \
|
|
||||||
{ \
|
|
||||||
enum { value = false }; \
|
|
||||||
}; \
|
|
||||||
/**/
|
|
||||||
|
|
||||||
AUX_HAS_REBIND_SPEC(void)
|
|
||||||
AUX_HAS_REBIND_SPEC(bool)
|
|
||||||
AUX_HAS_REBIND_SPEC(char)
|
|
||||||
AUX_HAS_REBIND_SPEC(signed char)
|
|
||||||
AUX_HAS_REBIND_SPEC(unsigned char)
|
|
||||||
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
|
||||||
AUX_HAS_REBIND_SPEC(wchar_t)
|
|
||||||
#endif
|
|
||||||
AUX_HAS_REBIND_SPEC(signed short)
|
|
||||||
AUX_HAS_REBIND_SPEC(unsigned short)
|
|
||||||
AUX_HAS_REBIND_SPEC(signed int)
|
|
||||||
AUX_HAS_REBIND_SPEC(unsigned int)
|
|
||||||
AUX_HAS_REBIND_SPEC(signed long)
|
|
||||||
AUX_HAS_REBIND_SPEC(unsigned long)
|
|
||||||
AUX_HAS_REBIND_SPEC(float)
|
|
||||||
AUX_HAS_REBIND_SPEC(double)
|
|
||||||
AUX_HAS_REBIND_SPEC(long double)
|
|
||||||
|
|
||||||
# undef AUX_HAS_REBIND_SPEC
|
|
||||||
|
|
||||||
#endif // BOOST_MSVC > 1300
|
|
||||||
#else
|
|
||||||
|
|
||||||
template< typename T >
|
|
||||||
struct has_rebind
|
|
||||||
{
|
|
||||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace aux
|
|
||||||
} // namespace mpl
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#endif // BOOST_MPL_AUX_HAS_REBIND_HPP_INCLUDED
|
#endif // BOOST_MPL_AUX_HAS_REBIND_HPP_INCLUDED
|
||||||
|
Reference in New Issue
Block a user