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

150 lines
3.8 KiB
C++
Raw Normal View History

2003-08-04 02:03:46 +00:00
#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
2003-08-05 02:13:04 +00:00
// + file: boost/mpl/aux_/lambda_no_ctps.hpp
2003-08-04 02:03:46 +00:00
// + last modified: 03/aug/03
// Copyright (c) 2001-03
2002-09-15 22:13:24 +00:00
// 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.
2003-08-04 02:03:46 +00:00
//
// See http://www.boost.org/libs/mpl for documentation.
2002-09-15 22:13:24 +00:00
#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"
2003-08-04 02:03:46 +00:00
# include "boost/mpl/void.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-08-04 02:03:46 +00:00
#if !defined(BOOST_MPL_NO_PREPROCESSED_HEADERS) \
&& !defined(BOOST_MPL_PREPROCESSING_MODE)
2002-09-15 22:13:24 +00:00
# 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
{
2003-08-04 02:03:46 +00:00
template< typename T, typename Tag > struct result_
2002-09-15 22:13:24 +00:00
{
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
2003-08-04 02:03:46 +00:00
template<
typename T
, typename Tag = void_
, bool Protect = true
>
2002-09-15 22:13:24 +00:00
struct lambda
{
// Metafunction forwarding confuses vc6
typedef typename aux::lambda_impl<
2002-12-09 05:20:25 +00:00
::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
>::template result_<T,Tag>::type type;
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) \
2003-08-04 02:03:46 +00:00
typedef typename lambda< \
2002-12-09 08:08:30 +00:00
typename F::BOOST_PP_CAT(arg,BOOST_PP_INC(i)) \
2003-08-04 02:03:46 +00:00
, Tag \
2002-09-15 22:13:24 +00:00
, false \
2003-08-04 02:03:46 +00:00
>::type BOOST_PP_CAT(arg,BOOST_PP_INC(i)); \
2002-09-15 22:13:24 +00:00
/**/
template<> struct lambda_impl<i,false>
{
2003-08-04 02:03:46 +00:00
template< typename F, typename Tag > struct result_
2002-09-15 22:13:24 +00:00
{
typedef typename F::rebind f_;
2003-08-04 02:03:46 +00:00
BOOST_MPL_PP_REPEAT(i, AUX_LAMBDA_INVOCATION, T)
2002-09-15 22:13:24 +00:00
typedef BOOST_PP_CAT(bind,i)<
f_
2003-08-04 02:03:46 +00:00
, AUX_LAMBDA_PARAMS(i, arg)
2002-09-15 22:13:24 +00:00
> type;
};
};
template<> struct lambda_impl<i,true>
{
2003-08-04 02:03:46 +00:00
template< typename F, typename Tag > struct result_
2002-09-15 22:13:24 +00:00
{
typedef typename F::rebind f_;
2003-08-04 02:03:46 +00:00
BOOST_MPL_PP_REPEAT(i, AUX_LAMBDA_INVOCATION, T)
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_
2003-08-04 02:03:46 +00:00
, AUX_LAMBDA_PARAMS(i, arg)
2002-09-15 22:13:24 +00:00
> > type;
};
};
# undef AUX_LAMBDA_INVOCATION
#undef i
#endif // BOOST_PP_IS_ITERATING