mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-03 14:54:30 +02:00
for_each reference_wrapper support
[SVN r16719]
This commit is contained in:
46
include/boost/mpl/aux_/unwrap.hpp
Normal file
46
include/boost/mpl/aux_/unwrap.hpp
Normal 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
|
@@ -21,8 +21,10 @@
|
|||||||
#include "boost/mpl/apply.hpp"
|
#include "boost/mpl/apply.hpp"
|
||||||
#include "boost/mpl/bool_c.hpp"
|
#include "boost/mpl/bool_c.hpp"
|
||||||
#include "boost/mpl/lambda.hpp"
|
#include "boost/mpl/lambda.hpp"
|
||||||
|
#include "boost/mpl/aux_/unwrap.hpp"
|
||||||
|
|
||||||
#include "boost/type_traits/is_same.hpp"
|
#include "boost/type_traits/is_same.hpp"
|
||||||
#include <boost/utility/value_init.hpp>
|
#include "boost/utility/value_init.hpp"
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace mpl {
|
namespace mpl {
|
||||||
@@ -33,13 +35,13 @@ template <bool done = true>
|
|||||||
struct for_each_impl
|
struct for_each_impl
|
||||||
{
|
{
|
||||||
template<
|
template<
|
||||||
typename Iterator
|
typename Iterator
|
||||||
, typename LastIterator
|
, typename LastIterator
|
||||||
, typename TransformFunc
|
, typename TransformFunc
|
||||||
, typename F
|
, typename F
|
||||||
>
|
>
|
||||||
static void execute(
|
static void execute(
|
||||||
Iterator*
|
Iterator*
|
||||||
, LastIterator*
|
, LastIterator*
|
||||||
, TransformFunc*
|
, TransformFunc*
|
||||||
, F
|
, F
|
||||||
@@ -52,13 +54,13 @@ template <>
|
|||||||
struct for_each_impl<false>
|
struct for_each_impl<false>
|
||||||
{
|
{
|
||||||
template<
|
template<
|
||||||
typename Iterator
|
typename Iterator
|
||||||
, typename LastIterator
|
, typename LastIterator
|
||||||
, typename TransformFunc
|
, typename TransformFunc
|
||||||
, typename F
|
, typename F
|
||||||
>
|
>
|
||||||
static void execute(
|
static void execute(
|
||||||
Iterator*
|
Iterator*
|
||||||
, LastIterator*
|
, LastIterator*
|
||||||
, TransformFunc*
|
, TransformFunc*
|
||||||
, F f
|
, F f
|
||||||
@@ -70,7 +72,7 @@ struct for_each_impl<false>
|
|||||||
// dwa 2002/9/10 -- make sure not to invoke undefined behavior
|
// dwa 2002/9/10 -- make sure not to invoke undefined behavior
|
||||||
// when we pass arg.
|
// when we pass arg.
|
||||||
value_initialized<arg> x;
|
value_initialized<arg> x;
|
||||||
f(get(x));
|
aux::unwrap(f, 0)(get(x));
|
||||||
|
|
||||||
typedef typename Iterator::next iter;
|
typedef typename Iterator::next iter;
|
||||||
for_each_impl<boost::is_same<iter,LastIterator>::value>::execute(
|
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
|
} // namespace aux
|
||||||
|
|
||||||
|
// agurt, 17/mar/02: pointer default parameters are necessary to workaround
|
||||||
|
// MSVC 6.5 function template signature's mangling bug
|
||||||
template<
|
template<
|
||||||
typename Sequence
|
typename Sequence
|
||||||
, typename TransformOp
|
, typename TransformOp
|
||||||
|
Reference in New Issue
Block a user