Files
boost_mpl/include/boost/mpl/aux_/lambda_no_ctps.hpp
T

137 lines
3.6 KiB
C++
Raw Normal View History

2002-09-15 22:13:24 +00:00
//-----------------------------------------------------------------------------
// boost mpl/lambda_no_ctps.hpp header file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2001-02
// Aleksey Gurtovoy
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appears in all copies and
// that both the copyright notice and this permission notice appear in
// supporting documentation. No representations are made about the
// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
#if !defined(BOOST_PP_IS_ITERATING)
///// header body
#ifndef BOOST_MPL_AUX_LAMBDA_NO_CTPS_HPP_INCLUDED
#define BOOST_MPL_AUX_LAMBDA_NO_CTPS_HPP_INCLUDED
#if !defined(BOOST_MPL_PREPROCESSING_MODE)
# include "boost/mpl/lambda_fwd.hpp"
# include "boost/mpl/bind.hpp"
# include "boost/mpl/protect.hpp"
2003-02-25 23:11:41 +00:00
# include "boost/mpl/bool.hpp"
2002-09-15 22:13:24 +00:00
# include "boost/mpl/aux_/template_arity.hpp"
#endif
#include "boost/mpl/aux_/config/use_preprocessed.hpp"
2003-01-05 08:49:46 +00:00
#if !defined(BOOST_MPL_NO_PREPROCESSED_HEADERS) && \
2002-09-15 22:13:24 +00:00
!defined(BOOST_MPL_PREPROCESSING_MODE)
# define BOOST_MPL_PREPROCESSED_HEADER lambda_no_ctps.hpp
# include "boost/mpl/aux_/include_preprocessed.hpp"
#else
2002-12-09 05:20:25 +00:00
# include "boost/mpl/aux_/config/nttp.hpp"
2002-09-15 22:13:24 +00:00
# include "boost/mpl/limits/arity.hpp"
# include "boost/mpl/aux_/preprocessor/params.hpp"
# include "boost/mpl/aux_/preprocessor/repeat.hpp"
# include "boost/preprocessor/iterate.hpp"
# include "boost/preprocessor/inc.hpp"
# include "boost/preprocessor/cat.hpp"
# include "boost/config.hpp"
namespace boost {
namespace mpl {
// local macros, #undef-ined at the end of the header
# define AUX_LAMBDA_PARAMS(i, param) \
BOOST_MPL_PP_PARAMS(i, param) \
/**/
namespace aux {
2002-12-09 05:20:25 +00:00
template< BOOST_MPL_AUX_NTTP_DECL(int, arity_), bool Protect > struct lambda_impl
2002-09-15 22:13:24 +00:00
{
template< typename T > struct result_
{
typedef T type;
};
};
#define BOOST_PP_ITERATION_PARAMS_1 \
(3,(1, BOOST_MPL_METAFUNCTION_MAX_ARITY, "boost/mpl/aux_/lambda_no_ctps.hpp"))
#include BOOST_PP_ITERATE()
} // namespace aux
template< typename T, bool Protect = true >
struct lambda
2002-12-09 05:20:25 +00:00
: aux::lambda_impl<
::boost::mpl::aux::template_arity<T>::value
2002-09-15 22:13:24 +00:00
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1200
2002-12-09 05:20:25 +00:00
, Protect
2002-09-15 22:13:24 +00:00
#else
2003-02-25 23:11:41 +00:00
, bool_<Protect>::value
2002-09-15 22:13:24 +00:00
#endif
2002-12-09 05:20:25 +00:00
>::template result_<T>
2002-09-15 22:13:24 +00:00
{
};
# undef AUX_LAMBDA_PARAMS
} // namespace mpl
} // namespace boost
#endif // BOOST_MPL_USE_PREPROCESSED_HEADERS
#endif // BOOST_MPL_AUX_LAMBDA_NO_CTPS_HPP_INCLUDED
///// iteration
#else
#define i BOOST_PP_FRAME_ITERATION(1)
2002-10-07 11:32:25 +00:00
# define AUX_LAMBDA_INVOCATION(unused, i, T) \
2002-09-15 22:13:24 +00:00
, typename lambda< \
2002-12-09 08:08:30 +00:00
typename F::BOOST_PP_CAT(arg,BOOST_PP_INC(i)) \
2002-09-15 22:13:24 +00:00
, false \
>::type \
/**/
template<> struct lambda_impl<i,false>
{
template< typename F > struct result_
{
typedef typename F::rebind f_;
typedef BOOST_PP_CAT(bind,i)<
f_
BOOST_MPL_PP_REPEAT(i, AUX_LAMBDA_INVOCATION, T)
> type;
};
};
template<> struct lambda_impl<i,true>
{
template< typename F > struct result_
{
typedef typename F::rebind f_;
2003-03-08 00:25:47 +00:00
typedef mpl::protect< BOOST_PP_CAT(bind,i)<
2002-09-15 22:13:24 +00:00
f_
BOOST_MPL_PP_REPEAT(i, AUX_LAMBDA_INVOCATION, T)
> > type;
};
};
# undef AUX_LAMBDA_INVOCATION
#undef i
#endif // BOOST_PP_IS_ITERATING