is_placeholder, is_bind_expression added.

[SVN r34468]
This commit is contained in:
Peter Dimov
2006-07-06 13:47:26 +00:00
parent c69a4ad382
commit bfe10df38a
6 changed files with 177 additions and 2 deletions
+38
View File
@@ -25,6 +25,7 @@
#include <boost/ref.hpp>
#include <boost/mem_fn.hpp>
#include <boost/type.hpp>
#include <boost/is_placeholder.hpp>
#include <boost/bind/arg.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/visit_each.hpp>
@@ -933,11 +934,32 @@ namespace _bi
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || (__SUNPRO_CC >= 0x530)
#if 0
template<class T> struct add_value
{
typedef _bi::value<T> type;
};
#else
template< class T, int I > struct add_value_2
{
typedef boost::arg<I> type;
};
template< class T > struct add_value_2< T, 0 >
{
typedef _bi::value< T > type;
};
template<class T> struct add_value
{
typedef typename add_value_2< T, boost::is_placeholder< T >::value >::type type;
};
#endif
template<class T> struct add_value< value<T> >
{
typedef _bi::value<T> type;
@@ -1194,6 +1216,22 @@ template<class V, class R, class F, class L> void visit_each( V & v, _bi::bind_t
#endif
// is_bind_expression
template< class T > struct is_bind_expression
{
enum _vt { value = 0 };
};
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
template< class R, class F, class L > struct is_bind_expression< _bi::bind_t< R, F, L > >
{
enum _vt { value = 1 };
};
#endif
// bind
#ifndef BOOST_BIND
+28 -2
View File
@@ -19,18 +19,44 @@
// See http://www.boost.org/libs/bind/bind.html for documentation.
//
#include <boost/config.hpp>
#include <boost/is_placeholder.hpp>
namespace boost
{
template<int I> class arg
template< int I > struct arg
{
arg()
{
}
template< class T > arg( T const & /* t */ )
{
// static assert I == is_placeholder<T>::value
typedef char T_must_be_placeholder[ I == is_placeholder<T>::value? 1: -1 ];
}
};
template<int I> bool operator==(arg<I> const &, arg<I> const &)
template< int I > bool operator==( arg<I> const &, arg<I> const & )
{
return true;
}
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
template< int I > struct is_placeholder< arg<I> >
{
enum _vt { value = I };
};
template< int I > struct is_placeholder< arg<I> (*) () >
{
enum _vt { value = I };
};
#endif
} // namespace boost
#endif // #ifndef BOOST_BIND_ARG_HPP_INCLUDED
+31
View File
@@ -0,0 +1,31 @@
#ifndef BOOST_IS_PLACEHOLDER_HPP_INCLUDED
#define BOOST_IS_PLACEHOLDER_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined( _MSC_VER ) && ( _MSC_VER >= 1020 )
# pragma once
#endif
// is_placeholder.hpp - TR1 is_placeholder metafunction
//
// Copyright (c) 2006 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
namespace boost
{
template< class T > struct is_placeholder
{
enum _vt { value = 0 };
};
} // namespace boost
#endif // #ifndef BOOST_IS_PLACEHOLDER_HPP_INCLUDED