adds functional module

[SVN r36955]
This commit is contained in:
Tobias Schwinger
2007-02-15 22:41:45 +00:00
parent f975648eea
commit 0ea1bbb067
34 changed files with 2593 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
// No include guard - this file is included multiple times intentionally.
#if !defined(BOOST_PP_IS_ITERATING)
# if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_GEN_RESULT_OF_SPEC_HPP_INCLUDED)
# include <boost/preprocessor/iteration/iterate.hpp>
# include <boost/preprocessor/repetition/enum_params.hpp>
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
# include <boost/preprocessor/facilities/intercept.hpp>
# include <boost/utility/result_of.hpp>
# include <boost/fusion/functional/adapter/detail/access.hpp>
# define BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_GEN_RESULT_OF_SPEC_HPP_INCLUDED
# endif
# if !defined(BOOST_FUSION_CLASS_TPL_PARAMS)
# error "BOOST_FUSION_CLASS_TPL_PARAMS undefined"
# endif
# if !defined(BOOST_FUSION_CLASS_TPL_SPEC)
# error "BOOST_FUSION_CLASS_TPL_SPEC undefined"
# endif
# if !defined(BOOST_FUSION_FUNC_OBJ_ARITY)
# define BOOST_PP_ITERATION_LIMITS (1,1)
# else
# define BOOST_PP_ITERATION_LIMITS (0,BOOST_FUSION_FUNC_OBJ_ARITY)
# endif
# define BOOST_PP_FILENAME_1 \
<boost/fusion/functional/adapter/detail/gen_result_of_spec.hpp>
namespace boost
{
#include BOOST_PP_ITERATE()
}
# undef BOOST_FUSION_CLASS_TPL_PARAMS
# undef BOOST_FUSION_CLASS_TPL_SPEC
# if defined(BOOST_FUSION_FUNC_OBJ_ARITY)
# undef BOOST_FUSION_FUNC_OBJ_ARITY
# endif
#else // defined(BOOST_PP_IS_ITERATING)
///////////////////////////////////////////////////////////////////////////////
//
// Preprocessor vertical repetition code
//
///////////////////////////////////////////////////////////////////////////////
# define N BOOST_PP_ITERATION()
template< BOOST_FUSION_CLASS_TPL_PARAMS
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A) >
struct result_of< BOOST_FUSION_CLASS_TPL_SPEC (BOOST_PP_ENUM_PARAMS(N,A)) >
{
typedef typename BOOST_FUSION_CLASS_TPL_SPEC ::template result
<BOOST_PP_ENUM_BINARY_PARAMS(N, typename fusion::detail::r2fp<A,
>::type BOOST_PP_INTERCEPT)>::type type;
};
template< BOOST_FUSION_CLASS_TPL_PARAMS
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A) >
struct result_of< BOOST_FUSION_CLASS_TPL_SPEC & (BOOST_PP_ENUM_PARAMS(N,A)) >
{
typedef typename BOOST_FUSION_CLASS_TPL_SPEC ::template result
<BOOST_PP_ENUM_BINARY_PARAMS(N, typename fusion::detail::r2fp<A,
>::type BOOST_PP_INTERCEPT)>::type type;
};
template< BOOST_FUSION_CLASS_TPL_PARAMS
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A) >
struct result_of< BOOST_FUSION_CLASS_TPL_SPEC const (BOOST_PP_ENUM_PARAMS(N,A)) >
{
typedef typename BOOST_FUSION_CLASS_TPL_SPEC ::template result
<BOOST_PP_ENUM_BINARY_PARAMS(N, typename fusion::detail::r2fp<A,
>::type BOOST_PP_INTERCEPT)>::type type;
};
template< BOOST_FUSION_CLASS_TPL_PARAMS
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A) >
struct result_of< BOOST_FUSION_CLASS_TPL_SPEC const & (BOOST_PP_ENUM_PARAMS(N,A)) >
{
typedef typename BOOST_FUSION_CLASS_TPL_SPEC ::template result
<BOOST_PP_ENUM_BINARY_PARAMS(N, typename fusion::detail::r2fp<A,
>::type BOOST_PP_INTERCEPT)>::type type;
};
# undef N
#endif

View File

@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
#if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_HAS_TYPE_HPP_INCLUDED)
#define BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_HAS_TYPE_HPP_INCLUDED
#include <boost/mpl/aux_/has_type.hpp>
namespace boost { namespace fusion { namespace detail
{
// Actually it's a sin... But MSVC's weird interpretation of ADL makes
// me do this - tosh.
using boost::mpl::aux::has_type;
}}}
#endif

View File

@@ -0,0 +1,60 @@
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
#if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_NULLARY_CALL_BASE_HPP_INCLUDED)
#define BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_NULLARY_CALL_BASE_HPP_INCLUDED
#include <boost/blank.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/fusion/sequence/container/vector/vector10.hpp>
#include <boost/fusion/functional/adapter/detail/has_type.hpp>
namespace boost { namespace fusion { namespace detail
{
struct reserved { };
template <class Derived, class Function, bool Enable = detail::has_type<
typename remove_reference<Function>::type
::template result<fusion::vector0> >::value>
struct nullary_call_base
{
template <typename T> inline void operator()(T reserved::*) const { }
protected:
typedef boost::blank r0;
};
template <class Derived, class Function>
struct nullary_call_base<Derived,Function,true>
{
private:
typedef typename remove_reference<Function>::type function;
protected:
typedef typename function::template result<fusion::vector0> r0;
public:
inline typename function::template result<fusion::vector0>::type
operator()() const
{
fusion::vector0 arg;
return static_cast<Derived const *>(this)->fnc_transformed(arg);
}
inline typename function::template result<fusion::vector0>::type
operator()()
{
fusion::vector0 arg;
return static_cast<Derived *>(this)->fnc_transformed(arg);
}
};
}}}
#endif

View File

@@ -0,0 +1,37 @@
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
#if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_ACCESS_HPP_INCLUDED)
#define BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_ACCESS_HPP_INCLUDED
namespace boost { namespace fusion { namespace detail
{
// const reference deduction for function templates that accept T const &
template <typename T> struct cref { typedef T const& type; };
template <typename T> struct cref<T&> { typedef T const& type; };
template <typename T> struct cref<T const> { typedef T const& type; };
// mutable reference deduction for function templates that accept T &
template <typename T> struct mref { typedef T & type; };
template <typename T> struct mref<T&> { typedef T & type; };
// generic reference deduction for function templates that are overloaded
// to accept both T const & and T &
template <typename T> struct gref { typedef T const& type; };
template <typename T> struct gref<T&> { typedef T & type; };
template <typename T> struct gref<T const> { typedef T const& type; };
// boost::result_of to Fusion PFO parameter
template <typename T> struct r2fp { typedef T const type; };
template <typename T> struct r2fp<T const> { typedef T const type; };
template <typename T> struct r2fp<T &> { typedef T type; };
}}}
#endif

View File

@@ -0,0 +1,102 @@
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
// No include guard - this file is included multiple times intentionally.
#if !defined(BOOST_PP_IS_ITERATING)
# if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_GEN_RESULT_OF_SPEC_HPP_INCLUDED)
# include <boost/preprocessor/iteration/iterate.hpp>
# include <boost/preprocessor/repetition/enum_params.hpp>
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
# include <boost/preprocessor/facilities/intercept.hpp>
# include <boost/utility/result_of.hpp>
# include <boost/fusion/functional/adapter/detail/access.hpp>
# define BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_GEN_RESULT_OF_SPEC_HPP_INCLUDED
# endif
# if !defined(BOOST_FUSION_CLASS_TPL_PARAMS)
# error "BOOST_FUSION_CLASS_TPL_PARAMS undefined"
# endif
# if !defined(BOOST_FUSION_CLASS_TPL_SPEC)
# error "BOOST_FUSION_CLASS_TPL_SPEC undefined"
# endif
# if !defined(BOOST_FUSION_FUNC_OBJ_ARITY)
# define BOOST_PP_ITERATION_LIMITS (1,1)
# else
# define BOOST_PP_ITERATION_LIMITS (0,BOOST_FUSION_FUNC_OBJ_ARITY)
# endif
# define BOOST_PP_FILENAME_1 \
<boost/fusion/functional/adapter/detail/gen_result_of_spec.hpp>
namespace boost
{
#include BOOST_PP_ITERATE()
}
# undef BOOST_FUSION_CLASS_TPL_PARAMS
# undef BOOST_FUSION_CLASS_TPL_SPEC
# if defined(BOOST_FUSION_FUNC_OBJ_ARITY)
# undef BOOST_FUSION_FUNC_OBJ_ARITY
# endif
#else // defined(BOOST_PP_IS_ITERATING)
///////////////////////////////////////////////////////////////////////////////
//
// Preprocessor vertical repetition code
//
///////////////////////////////////////////////////////////////////////////////
# define N BOOST_PP_ITERATION()
template< BOOST_FUSION_CLASS_TPL_PARAMS
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A) >
struct result_of< BOOST_FUSION_CLASS_TPL_SPEC (BOOST_PP_ENUM_PARAMS(N,A)) >
{
typedef typename BOOST_FUSION_CLASS_TPL_SPEC ::template result
<BOOST_PP_ENUM_BINARY_PARAMS(N, typename fusion::detail::r2fp<A,
>::type BOOST_PP_INTERCEPT)>::type type;
};
template< BOOST_FUSION_CLASS_TPL_PARAMS
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A) >
struct result_of< BOOST_FUSION_CLASS_TPL_SPEC & (BOOST_PP_ENUM_PARAMS(N,A)) >
{
typedef typename BOOST_FUSION_CLASS_TPL_SPEC ::template result
<BOOST_PP_ENUM_BINARY_PARAMS(N, typename fusion::detail::r2fp<A,
>::type BOOST_PP_INTERCEPT)>::type type;
};
template< BOOST_FUSION_CLASS_TPL_PARAMS
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A) >
struct result_of< BOOST_FUSION_CLASS_TPL_SPEC const (BOOST_PP_ENUM_PARAMS(N,A)) >
{
typedef typename BOOST_FUSION_CLASS_TPL_SPEC ::template result
<BOOST_PP_ENUM_BINARY_PARAMS(N, typename fusion::detail::r2fp<A,
>::type BOOST_PP_INTERCEPT)>::type type;
};
template< BOOST_FUSION_CLASS_TPL_PARAMS
BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A) >
struct result_of< BOOST_FUSION_CLASS_TPL_SPEC const & (BOOST_PP_ENUM_PARAMS(N,A)) >
{
typedef typename BOOST_FUSION_CLASS_TPL_SPEC ::template result
<BOOST_PP_ENUM_BINARY_PARAMS(N, typename fusion::detail::r2fp<A,
>::type BOOST_PP_INTERCEPT)>::type type;
};
# undef N
#endif

View File

@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
#if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_HAS_TYPE_HPP_INCLUDED)
#define BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_HAS_TYPE_HPP_INCLUDED
#include <boost/mpl/aux_/has_type.hpp>
namespace boost { namespace fusion { namespace detail
{
// Actually it's a sin... But MSVC's weird interpretation of ADL makes
// me do this - tosh.
using boost::mpl::aux::has_type;
}}}
#endif

View File

@@ -0,0 +1,60 @@
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
#if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_NULLARY_CALL_BASE_HPP_INCLUDED)
#define BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_NULLARY_CALL_BASE_HPP_INCLUDED
#include <boost/blank.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/fusion/sequence/container/vector/vector10.hpp>
#include <boost/fusion/functional/adapter/detail/has_type.hpp>
namespace boost { namespace fusion { namespace detail
{
struct reserved { };
template <class Derived, class Function, bool Enable = detail::has_type<
typename remove_reference<Function>::type
::template result<fusion::vector0> >::value>
struct nullary_call_base
{
template <typename T> inline void operator()(T reserved::*) const { }
protected:
typedef boost::blank r0;
};
template <class Derived, class Function>
struct nullary_call_base<Derived,Function,true>
{
private:
typedef typename remove_reference<Function>::type function;
protected:
typedef typename function::template result<fusion::vector0> r0;
public:
inline typename function::template result<fusion::vector0>::type
operator()() const
{
fusion::vector0 arg;
return static_cast<Derived const *>(this)->fnc_transformed(arg);
}
inline typename function::template result<fusion::vector0>::type
operator()()
{
fusion::vector0 arg;
return static_cast<Derived *>(this)->fnc_transformed(arg);
}
};
}}}
#endif

View File

@@ -0,0 +1,117 @@
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
#if !defined(BOOST_PP_IS_ITERATING)
# error "This file has to be included by a preprocessor loop construct!"
#elif BOOST_PP_ITERATION_DEPTH() == 1
# if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_POW2_EXPLODE_HPP_INCLUDED)
# include <boost/preprocessor/config/limits.hpp>
# include <boost/preprocessor/slot/slot.hpp>
# include <boost/preprocessor/arithmetic/dec.hpp>
# define BOOST_FUSION_FUNCTIONAL_ADAPTER_DETAIL_POW2_EXPLODE_HPP_INCLUDED
# endif
# define BOOST_PP_VALUE 0
# include BOOST_PP_ASSIGN_SLOT(1)
# define BOOST_PP_FILENAME_2 \
<boost/fusion/functional/adapter/detail/pow2_explode.hpp>
# define BOOST_PP_VALUE 1 << (N >> 4)
# if BOOST_PP_VALUE > BOOST_PP_LIMIT_ITERATION
# error "Preprocessor limit exceeded."
# endif
# include BOOST_PP_ASSIGN_SLOT(2)
# define BOOST_PP_ITERATION_LIMITS (0,BOOST_PP_DEC(BOOST_PP_SLOT_2()))
# include BOOST_PP_ITERATE()
#elif BOOST_PP_ITERATION_DEPTH() == 2
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# if BOOST_PP_SLOT_1() < 1 << N
# include BOOST_PP_INDIRECT_SELF
# define BOOST_PP_VALUE BOOST_PP_SLOT_1() + 1
# include BOOST_PP_ASSIGN_SLOT(1)
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# endif
#endif

View File

@@ -0,0 +1,71 @@
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
// No include guard - this file is included multiple times intentionally.
#if BOOST_PP_SLOT_1() & 0x001
# define PT0 T0 &
#else
# define PT0 T0 const &
#endif
#if BOOST_PP_SLOT_1() & 0x002
# define PT1 T1 &
#else
# define PT1 T1 const &
#endif
#if BOOST_PP_SLOT_1() & 0x004
# define PT2 T2 &
#else
# define PT2 T2 const &
#endif
#if BOOST_PP_SLOT_1() & 0x008
# define PT3 T3 &
#else
# define PT3 T3 const &
#endif
#if BOOST_PP_SLOT_1() & 0x010
# define PT4 T4 &
#else
# define PT4 T4 const &
#endif
#if BOOST_PP_SLOT_1() & 0x020
# define PT5 T5 &
#else
# define PT5 T5 const &
#endif
#if BOOST_PP_SLOT_1() & 0x040
# define PT6 T6 &
#else
# define PT6 T6 const &
#endif
#if BOOST_PP_SLOT_1() & 0x080
# define PT7 T7 &
#else
# define PT7 T7 const &
#endif
#if BOOST_PP_SLOT_1() & 0x100
# define PT8 T8 &
#else
# define PT8 T8 const &
#endif
#if BOOST_PP_SLOT_1() & 0x200
# define PT9 T9 &
#else
# define PT9 T9 const &
#endif
#if BOOST_PP_SLOT_1() & 0x400
# define PT10 T10 &
#else
# define PT10 T10 const &
#endif
#if BOOST_PP_SLOT_1() & 0x800
# define PT11 T11 &
#else
# define PT11 T11 const &
#endif

View File

@@ -0,0 +1,23 @@
/*=============================================================================
Copyright (c) 2006-2007 Tobias Schwinger
Use modification and distribution are subject to 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).
==============================================================================*/
// No include guard - this file is included multiple times intentionally.
#undef PT0
#undef PT1
#undef PT2
#undef PT3
#undef PT4
#undef PT5
#undef PT6
#undef PT7
#undef PT8
#undef PT9
#undef PT10
#undef PT11