for_each reference_wrapper support

[SVN r16719]
This commit is contained in:
Aleksey Gurtovoy
2002-12-30 08:12:55 +00:00
parent 090c80b675
commit 37efd60dc9
2 changed files with 64 additions and 16 deletions

View File

@@ -0,0 +1,46 @@
//-----------------------------------------------------------------------------
// boost mpl/aux_/unwrap.hpp header file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2001 David Abrahams
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
#ifndef BOOST_MPL_AUX_UNWRAP_HPP_INCLUDED
#define BOOST_MPL_AUX_UNWRAP_HPP_INCLUDED
#include "boost/ref.hpp"
namespace boost { namespace mpl { namespace aux {
template< typename F >
inline
F& unwrap(F& f, long)
{
return f;
}
template< typename F >
inline
F&
unwrap(reference_wrapper<F>& f, int)
{
return f;
}
template< typename F >
inline
F&
unwrap(reference_wrapper<F> const& f, int)
{
return f;
}
}}} // namespace boost::mpl::aux
#endif // BOOST_MPL_AUX_UNWRAP_HPP_INCLUDED

View File

@@ -21,8 +21,10 @@
#include "boost/mpl/apply.hpp"
#include "boost/mpl/bool_c.hpp"
#include "boost/mpl/lambda.hpp"
#include "boost/mpl/aux_/unwrap.hpp"
#include "boost/type_traits/is_same.hpp"
#include <boost/utility/value_init.hpp>
#include "boost/utility/value_init.hpp"
namespace boost {
namespace mpl {
@@ -33,13 +35,13 @@ template <bool done = true>
struct for_each_impl
{
template<
typename Iterator
, typename LastIterator
, typename TransformFunc
, typename F
>
typename Iterator
, typename LastIterator
, typename TransformFunc
, typename F
>
static void execute(
Iterator*
Iterator*
, LastIterator*
, TransformFunc*
, F
@@ -52,13 +54,13 @@ template <>
struct for_each_impl<false>
{
template<
typename Iterator
, typename LastIterator
, typename TransformFunc
, typename F
>
typename Iterator
, typename LastIterator
, typename TransformFunc
, typename F
>
static void execute(
Iterator*
Iterator*
, LastIterator*
, TransformFunc*
, F f
@@ -70,7 +72,7 @@ struct for_each_impl<false>
// dwa 2002/9/10 -- make sure not to invoke undefined behavior
// when we pass arg.
value_initialized<arg> x;
f(get(x));
aux::unwrap(f, 0)(get(x));
typedef typename Iterator::next iter;
for_each_impl<boost::is_same<iter,LastIterator>::value>::execute(
@@ -78,10 +80,10 @@ struct for_each_impl<false>
}
};
// agurt, 17/mar/02: pointer default parameters are necessary to workaround
// MSVC 6.5 function template signature's mangling bug
} // namespace aux
// agurt, 17/mar/02: pointer default parameters are necessary to workaround
// MSVC 6.5 function template signature's mangling bug
template<
typename Sequence
, typename TransformOp