Fix for lambda expressions with bound reference types

[SVN r16285]
This commit is contained in:
Dave Abrahams
2002-11-16 19:46:31 +00:00
parent 35775fc553
commit 8964d1f1e1
4 changed files with 113 additions and 23 deletions

View File

@@ -23,6 +23,10 @@
#include "boost/mpl/aux_/config/overload_resolution.hpp"
#include "boost/config.hpp"
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
# include "boost/type_traits/is_reference.hpp"
#endif
namespace boost {
namespace mpl {
namespace aux {
@@ -57,21 +61,40 @@ struct has_rebind
// note that the code is _not_ standard-conforming, but it works,
// and it resolves some nasty ICE cases with the above implementation
template< typename T, typename rebind = int >
struct has_rebind : T
template < bool ref = true >
struct has_rebind_impl
{
private:
static no_tag test(int*);
static yes_tag test(...);
template < typename T > struct apply
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
};
public:
BOOST_STATIC_CONSTANT(bool, value =
sizeof(test(static_cast<rebind*>(0))) != sizeof(no_tag)
);
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,int> \
template<> struct has_rebind<T> \
{ \
enum { value = false }; \
}; \

View File

@@ -88,11 +88,32 @@ aux::yes_tag is_bind_helper(arg<N>*);
template< typename F, typename T > aux::yes_tag is_bind_helper(bind1st< F,T >*);
template< typename F, typename T > aux::yes_tag is_bind_helper(bind2nd< F,T >*);
template< typename T > struct is_bind_template
template < bool ref = true >
struct is_bind_template_impl
{
template < typename T >
struct apply
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
};
template <>
struct is_bind_template_impl<false>
{
template< typename T >
struct apply
{
BOOST_STATIC_CONSTANT(bool, value = sizeof(aux::is_bind_helper(static_cast<T*>(0)))
== sizeof(aux::yes_tag)
);
};
};
template< typename T > struct is_bind_template
: is_bind_template_impl<boost::detail::is_reference_impl< T >::value>
::template apply< T >
{
BOOST_STATIC_CONSTANT(bool, value = sizeof(aux::is_bind_helper(static_cast<T*>(0)))
== sizeof(aux::yes_tag)
);
};
} // namespace aux

View File

@@ -88,11 +88,32 @@ aux::yes_tag is_bind_helper(arg<N>*);
template< typename F, typename T > aux::yes_tag is_bind_helper(bind1st< F,T >*);
template< typename F, typename T > aux::yes_tag is_bind_helper(bind2nd< F,T >*);
template< typename T > struct is_bind_template
template < bool ref = true >
struct is_bind_template_impl
{
template < typename T >
struct apply
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
};
template <>
struct is_bind_template_impl<false>
{
template< typename T >
struct apply
{
BOOST_STATIC_CONSTANT(bool, value = sizeof(aux::is_bind_helper(static_cast<T*>(0)))
== sizeof(aux::yes_tag)
);
};
};
template< typename T > struct is_bind_template
: is_bind_template_impl<boost::detail::is_reference_impl< T >::value>
::template apply< T >
{
BOOST_STATIC_CONSTANT(bool, value = sizeof(aux::is_bind_helper(static_cast<T*>(0)))
== sizeof(aux::yes_tag)
);
};
} // namespace aux

View File

@@ -25,6 +25,11 @@
#include "boost/mpl/aux_/config/bind.hpp"
#include "boost/mpl/aux_/config/lambda.hpp"
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
# include "boost/type_traits/is_reference.hpp"
#endif
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
# include "boost/mpl/placeholder.hpp"
# include "boost/mpl/void.hpp"
@@ -295,12 +300,32 @@ aux::yes_tag is_bind_helper(arg<N>*);
template< typename F, typename T > aux::yes_tag is_bind_helper(bind1st<F,T>*);
template< typename F, typename T > aux::yes_tag is_bind_helper(bind2nd<F,T>*);
template< typename T > struct is_bind_template
template < bool ref = true >
struct is_bind_template_impl
{
template < typename T >
struct apply
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
};
template <>
struct is_bind_template_impl<false>
{
template< typename T >
struct apply
{
BOOST_STATIC_CONSTANT(bool, value = sizeof(aux::is_bind_helper(static_cast<T*>(0)))
== sizeof(aux::yes_tag)
);
};
};
template< typename T > struct is_bind_template
: is_bind_template_impl<boost::detail::is_reference_impl< T >::value>
::template apply< T >
{
BOOST_STATIC_CONSTANT(bool, value =
sizeof(aux::is_bind_helper(static_cast<T*>(0)))
== sizeof(aux::yes_tag)
);
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION