diff --git a/include/boost/fusion/functional.hpp b/include/boost/fusion/functional.hpp new file mode 100644 index 00000000..12662d97 --- /dev/null +++ b/include/boost/fusion/functional.hpp @@ -0,0 +1,17 @@ +/*============================================================================= + 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_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_HPP_INCLUDED + +#include +#include +#include + +#endif + diff --git a/include/boost/fusion/functional/adapter.hpp b/include/boost/fusion/functional/adapter.hpp new file mode 100644 index 00000000..734dac39 --- /dev/null +++ b/include/boost/fusion/functional/adapter.hpp @@ -0,0 +1,18 @@ +/*============================================================================= + 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_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_ADAPTER_HPP_INCLUDED +#include +#include +#include +#include +#include +#include +#include +#endif diff --git a/include/boost/fusion/functional/adapter/detail/Attic/gen_result_of_spec.hpp b/include/boost/fusion/functional/adapter/detail/Attic/gen_result_of_spec.hpp new file mode 100644 index 00000000..29335dc3 --- /dev/null +++ b/include/boost/fusion/functional/adapter/detail/Attic/gen_result_of_spec.hpp @@ -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 +# include +# include +# include +# include + +# include + +# include + +# 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 \ + + +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 + ::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 + ::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 + ::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 + ::type BOOST_PP_INTERCEPT)>::type type; + }; + +# undef N + +#endif + diff --git a/include/boost/fusion/functional/adapter/detail/Attic/has_type.hpp b/include/boost/fusion/functional/adapter/detail/Attic/has_type.hpp new file mode 100644 index 00000000..98056a26 --- /dev/null +++ b/include/boost/fusion/functional/adapter/detail/Attic/has_type.hpp @@ -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 + +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 diff --git a/include/boost/fusion/functional/adapter/detail/Attic/nullary_call_base.hpp b/include/boost/fusion/functional/adapter/detail/Attic/nullary_call_base.hpp new file mode 100644 index 00000000..efef076e --- /dev/null +++ b/include/boost/fusion/functional/adapter/detail/Attic/nullary_call_base.hpp @@ -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 + +#include + +#include +#include + +namespace boost { namespace fusion { namespace detail +{ + struct reserved { }; + + template ::type + ::template result >::value> + struct nullary_call_base + { + template inline void operator()(T reserved::*) const { } + protected: + typedef boost::blank r0; + }; + + template + struct nullary_call_base + { + private: + typedef typename remove_reference::type function; + protected: + typedef typename function::template result r0; + public: + + inline typename function::template result::type + operator()() const + { + fusion::vector0 arg; + return static_cast(this)->fnc_transformed(arg); + } + + inline typename function::template result::type + operator()() + { + fusion::vector0 arg; + return static_cast(this)->fnc_transformed(arg); + } + }; + +}}} + +#endif + diff --git a/include/boost/fusion/functional/adapter/detail/access.hpp b/include/boost/fusion/functional/adapter/detail/access.hpp new file mode 100644 index 00000000..29f4ad97 --- /dev/null +++ b/include/boost/fusion/functional/adapter/detail/access.hpp @@ -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 struct cref { typedef T const& type; }; + template struct cref { typedef T const& type; }; + template struct cref { typedef T const& type; }; + + // mutable reference deduction for function templates that accept T & + template struct mref { typedef T & type; }; + template struct mref { typedef T & type; }; + + // generic reference deduction for function templates that are overloaded + // to accept both T const & and T & + template struct gref { typedef T const& type; }; + template struct gref { typedef T & type; }; + template struct gref { typedef T const& type; }; + + // boost::result_of to Fusion PFO parameter + template struct r2fp { typedef T const type; }; + template struct r2fp { typedef T const type; }; + template struct r2fp { typedef T type; }; + +}}} + +#endif + diff --git a/include/boost/fusion/functional/adapter/detail/gen_result_of_spec.hpp b/include/boost/fusion/functional/adapter/detail/gen_result_of_spec.hpp new file mode 100644 index 00000000..29335dc3 --- /dev/null +++ b/include/boost/fusion/functional/adapter/detail/gen_result_of_spec.hpp @@ -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 +# include +# include +# include +# include + +# include + +# include + +# 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 \ + + +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 + ::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 + ::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 + ::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 + ::type BOOST_PP_INTERCEPT)>::type type; + }; + +# undef N + +#endif + diff --git a/include/boost/fusion/functional/adapter/detail/has_type.hpp b/include/boost/fusion/functional/adapter/detail/has_type.hpp new file mode 100644 index 00000000..98056a26 --- /dev/null +++ b/include/boost/fusion/functional/adapter/detail/has_type.hpp @@ -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 + +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 diff --git a/include/boost/fusion/functional/adapter/detail/nullary_call_base.hpp b/include/boost/fusion/functional/adapter/detail/nullary_call_base.hpp new file mode 100644 index 00000000..efef076e --- /dev/null +++ b/include/boost/fusion/functional/adapter/detail/nullary_call_base.hpp @@ -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 + +#include + +#include +#include + +namespace boost { namespace fusion { namespace detail +{ + struct reserved { }; + + template ::type + ::template result >::value> + struct nullary_call_base + { + template inline void operator()(T reserved::*) const { } + protected: + typedef boost::blank r0; + }; + + template + struct nullary_call_base + { + private: + typedef typename remove_reference::type function; + protected: + typedef typename function::template result r0; + public: + + inline typename function::template result::type + operator()() const + { + fusion::vector0 arg; + return static_cast(this)->fnc_transformed(arg); + } + + inline typename function::template result::type + operator()() + { + fusion::vector0 arg; + return static_cast(this)->fnc_transformed(arg); + } + }; + +}}} + +#endif + diff --git a/include/boost/fusion/functional/adapter/detail/pow2_explode.hpp b/include/boost/fusion/functional/adapter/detail/pow2_explode.hpp new file mode 100644 index 00000000..3d5afcb8 --- /dev/null +++ b/include/boost/fusion/functional/adapter/detail/pow2_explode.hpp @@ -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 +# include +# include +# 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 \ + +# 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 + diff --git a/include/boost/fusion/functional/adapter/detail/pt_def.hpp b/include/boost/fusion/functional/adapter/detail/pt_def.hpp new file mode 100644 index 00000000..8f85cf44 --- /dev/null +++ b/include/boost/fusion/functional/adapter/detail/pt_def.hpp @@ -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 + diff --git a/include/boost/fusion/functional/adapter/detail/pt_undef.hpp b/include/boost/fusion/functional/adapter/detail/pt_undef.hpp new file mode 100644 index 00000000..dca50043 --- /dev/null +++ b/include/boost/fusion/functional/adapter/detail/pt_undef.hpp @@ -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 + diff --git a/include/boost/fusion/functional/adapter/fused.hpp b/include/boost/fusion/functional/adapter/fused.hpp new file mode 100644 index 00000000..21c25d84 --- /dev/null +++ b/include/boost/fusion/functional/adapter/fused.hpp @@ -0,0 +1,78 @@ +/*============================================================================= + 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_FUSED_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_HPP_INCLUDED + +#include + +#include +#include + +namespace boost { namespace fusion +{ + template class fused; + + //----- ---- --- -- - - - - + + template + class fused + { + Function fnc_transformed; + + typedef typename boost::add_reference::type func_fwd_t; + typedef typename detail::call_param::type func_const_fwd_t; + + public: + + inline explicit fused(func_const_fwd_t f = Function()) + : fnc_transformed(f) + { } + + template + inline typename result_of::invoke::type + operator()(Seq const & s) const + { + return fusion::invoke(this->fnc_transformed,s); + } + + template + inline typename result_of::invoke::type + operator()(Seq const & s) + { + return fusion::invoke(this->fnc_transformed,s); + } + + template + inline typename result_of::invoke::type + operator()(Seq & s) const + { + return fusion::invoke(this->fnc_transformed,s); + } + + template + inline typename result_of::invoke::type + operator()(Seq & s) + { + return fusion::invoke(this->fnc_transformed,s); + } + + template + struct result + : result_of::invoke + { }; + }; + +}} + +#define BOOST_FUSION_CLASS_TPL_PARAMS typename F +#define BOOST_FUSION_CLASS_TPL_SPEC fusion::fused +#include + +#endif + diff --git a/include/boost/fusion/functional/adapter/fused_function_object.hpp b/include/boost/fusion/functional/adapter/fused_function_object.hpp new file mode 100644 index 00000000..300b1d42 --- /dev/null +++ b/include/boost/fusion/functional/adapter/fused_function_object.hpp @@ -0,0 +1,83 @@ +/*============================================================================= + 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_FUSED_FUNCTION_OBJECT_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_FUNCTION_OBJECT_HPP_INCLUDED + +#include + +#include +#include + +namespace boost { namespace fusion +{ + template class fused_function_object; + + //----- ---- --- -- - - - - + + template + class fused_function_object + { + Function fnc_transformed; + + typedef typename boost::add_reference::type func_fwd_t; + typedef typename detail::call_param::type func_const_fwd_t; + + public: + + inline explicit fused_function_object(func_const_fwd_t f = Function()) + : fnc_transformed(f) + { } + + template + inline typename result_of::invoke_function_object::type operator()(Seq const & s) const + { + return fusion::invoke_function_object< + func_const_fwd_t >(this->fnc_transformed,s); + } + + template + inline typename result_of::invoke_function_object::type + operator()(Seq const & s) + { + return fusion::invoke_function_object< + func_fwd_t >(this->fnc_transformed,s); + } + + template + inline typename result_of::invoke_function_object::type + operator()(Seq & s) const + { + return fusion::invoke_function_object< + func_const_fwd_t >(this->fnc_transformed,s); + } + + template + inline typename result_of::invoke_function_object::type + operator()(Seq & s) + { + return fusion::invoke_function_object< + func_fwd_t >(this->fnc_transformed,s); + } + + template + struct result + : result_of::invoke_function_object + { }; + }; + +}} + +#define BOOST_FUSION_CLASS_TPL_PARAMS typename F +#define BOOST_FUSION_CLASS_TPL_SPEC fusion::fused_function_object +#include + +#endif + diff --git a/include/boost/fusion/functional/adapter/fused_procedure.hpp b/include/boost/fusion/functional/adapter/fused_procedure.hpp new file mode 100644 index 00000000..43c94759 --- /dev/null +++ b/include/boost/fusion/functional/adapter/fused_procedure.hpp @@ -0,0 +1,79 @@ +/*============================================================================= + 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_FUSED_PROCEDURE_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_PROCEDURE_HPP_INCLUDED + +#include + +#include +#include + +namespace boost { namespace fusion +{ + template class fused_procedure; + + //----- ---- --- -- - - - - + + template + class fused_procedure + { + Function fnc_transformed; + + typedef typename boost::add_reference::type func_fwd_t; + typedef typename detail::call_param::type func_const_fwd_t; + + public: + + inline explicit fused_procedure(func_const_fwd_t f = Function()) + : fnc_transformed(f) + { } + + template + inline typename result_of::invoke_procedure::type + operator()(Seq const & s) const + { + return fusion::invoke_procedure< + func_const_fwd_t >(this->fnc_transformed,s); + } + + template + inline typename result_of::invoke_procedure::type + operator()(Seq const & s) + { + return fusion::invoke_procedure< + func_fwd_t >(this->fnc_transformed,s); + } + + template + inline typename result_of::invoke_procedure::type + operator()(Seq & s) const + { + return fusion::invoke_procedure< + func_const_fwd_t >(this->fnc_transformed,s); + } + + template + inline typename result_of::invoke_procedure::type + operator()(Seq & s) + { + return fusion::invoke_procedure< + func_fwd_t >(this->fnc_transformed,s); + } + + template + struct result + : result_of::invoke_procedure + { }; + + typedef void result_type; + }; +}} + +#endif + diff --git a/include/boost/fusion/functional/adapter/limits.hpp b/include/boost/fusion/functional/adapter/limits.hpp new file mode 100644 index 00000000..fa2e5a3b --- /dev/null +++ b/include/boost/fusion/functional/adapter/limits.hpp @@ -0,0 +1,36 @@ +/*============================================================================= + 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_LIMITS_HPP_INCLUDED) +# define BOOST_FUSION_FUNCTIONAL_ADAPTER_LIMITS_HPP_INCLUDED + +# include + +# if !defined(BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY) +# define BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY 6 +# elif BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY > FUSION_MAX_VECTOR_SIZE +# error "BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY > FUSION_MAX_VECTOR_SIZE" +# endif +# if !defined(BOOST_FUSION_UNFUSED_RVALUE_ARGS_MAX_ARITY) +# define BOOST_FUSION_UNFUSED_RVALUE_ARGS_MAX_ARITY 6 +# elif BOOST_FUSION_UNFUSED_RVALUE_ARGS_MAX_ARITY > FUSION_MAX_VECTOR_SIZE +# error "BOOST_FUSION_UNFUSED_RVALUE_ARGS_MAX_ARITY > FUSION_MAX_VECTOR_SIZE" +# endif +# if !defined(BOOST_FUSION_UNFUSED_LVALUE_ARGS_MAX_ARITY) +# define BOOST_FUSION_UNFUSED_LVALUE_ARGS_MAX_ARITY 6 +# elif BOOST_FUSION_UNFUSED_LVALUE_ARGS_MAX_ARITY > FUSION_MAX_VECTOR_SIZE +# error "BOOST_FUSION_UNFUSED_LVALUE_ARGS_MAX_ARITY > FUSION_MAX_VECTOR_SIZE" +# endif +# if !defined(BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY) +# define BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY 6 +# elif BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE +# error "BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE" +# endif + +#endif + diff --git a/include/boost/fusion/functional/adapter/unfused_generic.hpp b/include/boost/fusion/functional/adapter/unfused_generic.hpp new file mode 100644 index 00000000..6cf811ee --- /dev/null +++ b/include/boost/fusion/functional/adapter/unfused_generic.hpp @@ -0,0 +1,163 @@ +/*============================================================================= + 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_UNFUSED_GENERIC_HPP_INCLUDED) +#if !defined(BOOST_PP_IS_ITERATING) + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +namespace boost { namespace fusion +{ + template class unfused_generic; + + //----- ---- --- -- - - - - + + struct void_; + + template class unfused_generic + : public detail::nullary_call_base, Function> + { + Function fnc_transformed; + + template + friend struct detail::nullary_call_base; + + typedef detail::nullary_call_base< + fusion::unfused_generic, Function > base; + + typedef typename boost::remove_reference::type function; + typedef typename detail::call_param::type func_const_fwd_t; + + public: + + inline explicit unfused_generic(func_const_fwd_t f = Function()) + : fnc_transformed(f) + { } + + using base::operator(); + + template < + BOOST_PP_ENUM_BINARY_PARAMS(BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY, + typename T, = fusion::void_ BOOST_PP_INTERCEPT), + class _ = fusion::void_ + > + struct result; + + template + struct result< + BOOST_PP_ENUM_PARAMS(BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY, + fusion::void_ BOOST_PP_INTERCEPT),_> + : base::r0 + { }; + + #define BOOST_FUSION_CODE(tpl_params,arg_types,params,args) \ + template \ + inline typename function::template result< \ + BOOST_PP_CAT(fusion::vector,N) >::type \ + operator()(params) const \ + { \ + BOOST_PP_CAT(fusion::vector,N) arg(args); \ + return this->fnc_transformed(arg); \ + } \ + template \ + inline typename function::template result< \ + BOOST_PP_CAT(fusion::vector,N) >::type \ + operator()(params) \ + { \ + BOOST_PP_CAT(fusion::vector,N) arg(args); \ + return this->fnc_transformed(arg); \ + } + + #define BOOST_PP_INDIRECT_SELF \ + + #define BOOST_PP_FILENAME_1 \ + + #define BOOST_PP_ITERATION_LIMITS \ + (1,BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY) + #define N BOOST_PP_ITERATION_1 + #include BOOST_PP_ITERATE() + #undef N + #undef BOOST_FUSION_CODE + }; +}} + +#define BOOST_FUSION_CLASS_TPL_PARAMS class F +#define BOOST_FUSION_CLASS_TPL_SPEC fusion::unfused_generic +#define BOOST_FUSION_FUNC_OBJ_ARITY BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY +#include + +#define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_GENERIC_HPP_INCLUDED +#else // defined(BOOST_PP_IS_ITERATING) +/////////////////////////////////////////////////////////////////////////////// +// +// Preprocessor vertical repetition code +// +/////////////////////////////////////////////////////////////////////////////// + +#include + +#if BOOST_PP_SLOT_1() == 0 + template + struct result +#if N < BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY + < BOOST_PP_ENUM_PARAMS(N,T), + BOOST_PP_ENUM_PARAMS( + BOOST_PP_SUB(BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY,N), + fusion::void_ BOOST_PP_INTERCEPT), _ > +#endif + : function::template result< BOOST_PP_CAT(fusion::vector,N)< + BOOST_PP_ENUM_BINARY_PARAMS(N,typename detail::gref::type + BOOST_PP_INTERCEPT) > > + { }; +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400)) + template + inline typename function::template result< + BOOST_PP_CAT(fusion::vector,N) >::type + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a)) const + { + BOOST_PP_CAT(fusion::vector,N) + arg(BOOST_PP_ENUM_PARAMS(N,a)); + return this->fnc_transformed(arg); + } + template + inline typename function::template result< + BOOST_PP_CAT(fusion::vector,N) >::type + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a)) + { + BOOST_PP_CAT(fusion::vector,N) + arg(BOOST_PP_ENUM_PARAMS(N,a)); + return this->fnc_transformed(arg); + } +#else + BOOST_FUSION_CODE(BOOST_PP_ENUM_PARAMS(N,typename T), + BOOST_PP_ENUM_PARAMS(N,PT), BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a), + BOOST_PP_ENUM_PARAMS(N,a) ) + // ...generates uglier code but is faster - it caches ENUM_* +#endif + +#include + +#endif // defined(BOOST_PP_IS_ITERATING) +#endif + diff --git a/include/boost/fusion/functional/adapter/unfused_lvalue_args.hpp b/include/boost/fusion/functional/adapter/unfused_lvalue_args.hpp new file mode 100644 index 00000000..a0152fb2 --- /dev/null +++ b/include/boost/fusion/functional/adapter/unfused_lvalue_args.hpp @@ -0,0 +1,130 @@ +/*============================================================================= + 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_UNFUSED_LVALUE_ARGS_HPP_INCLUDED) +#if !defined(BOOST_PP_IS_ITERATING) + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +namespace boost { namespace fusion +{ + template class unfused_lvalue_args; + + //----- ---- --- -- - - - - + + struct void_; + + template class unfused_lvalue_args + : public detail::nullary_call_base + , Function> + { + Function fnc_transformed; + + template + friend struct detail::nullary_call_base; + + typedef detail::nullary_call_base< + fusion::unfused_lvalue_args, Function > base; + + typedef typename boost::remove_reference::type function; + typedef typename detail::call_param::type func_const_fwd_t; + + public: + + inline explicit unfused_lvalue_args(func_const_fwd_t f = function()) + : fnc_transformed(f) + { } + + using base::operator(); + + template < + BOOST_PP_ENUM_BINARY_PARAMS( + BOOST_FUSION_UNFUSED_LVALUE_ARGS_MAX_ARITY, + typename T, = fusion::void_ BOOST_PP_INTERCEPT ), + class _ = fusion::void_ > + struct result; + + template + struct result + : base::r0 + { }; + + #define BOOST_PP_FILENAME_1 \ + + #define BOOST_PP_ITERATION_LIMITS \ + (1,BOOST_FUSION_UNFUSED_LVALUE_ARGS_MAX_ARITY) + #include BOOST_PP_ITERATE() + }; +}} + +#define BOOST_FUSION_CLASS_TPL_PARAMS class F +#define BOOST_FUSION_CLASS_TPL_SPEC fusion::unfused_lvalue_args +#define BOOST_FUSION_FUNC_OBJ_ARITY BOOST_FUSION_UNFUSED_LVALUE_ARGS_MAX_ARITY +#include + +#define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_LVALUE_ARGS_HPP_INCLUDED +#else // defined(BOOST_PP_IS_ITERATING) +//////////////////////////////////////////////////////////////////////////////// +// +// Preprocessor vertical repetition code +// +//////////////////////////////////////////////////////////////////////////////// +#define N BOOST_PP_ITERATION() + + template + struct result +#if N < BOOST_FUSION_UNFUSED_LVALUE_ARGS_MAX_ARITY + < BOOST_PP_ENUM_PARAMS(N,T), + BOOST_PP_ENUM_PARAMS( + BOOST_PP_SUB(BOOST_FUSION_UNFUSED_LVALUE_ARGS_MAX_ARITY,N), + fusion::void_ BOOST_PP_INTERCEPT), _ > +#endif + : function::template result< BOOST_PP_CAT(fusion::vector,N)< + BOOST_PP_ENUM_BINARY_PARAMS(N,typename detail::mref::type + BOOST_PP_INTERCEPT) > > + { }; + + template + inline typename function::template result >::type + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) const + { + BOOST_PP_CAT(fusion::vector,N)< + BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT) > + arg(BOOST_PP_ENUM_PARAMS(N,a)); + return this->fnc_transformed(arg); + } + + template + inline typename function::template result >::type + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) + { + BOOST_PP_CAT(fusion::vector,N)< + BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT) > + arg(BOOST_PP_ENUM_PARAMS(N,a)); + return this->fnc_transformed(arg); + } +#undef N +#endif // defined(BOOST_PP_IS_ITERATING) +#endif + diff --git a/include/boost/fusion/functional/adapter/unfused_rvalue_args.hpp b/include/boost/fusion/functional/adapter/unfused_rvalue_args.hpp new file mode 100644 index 00000000..21856bff --- /dev/null +++ b/include/boost/fusion/functional/adapter/unfused_rvalue_args.hpp @@ -0,0 +1,131 @@ +/*============================================================================= + 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_UNFUSED_RVALUE_ARGS_HPP_INCLUDED) +#if !defined(BOOST_PP_IS_ITERATING) + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +namespace boost { namespace fusion +{ + template class unfused_rvalue_args; + + //----- ---- --- -- - - - - + + struct void_; + + template class unfused_rvalue_args + : public detail::nullary_call_base + , Function> + { + Function fnc_transformed; + + template + friend struct detail::nullary_call_base; + + typedef detail::nullary_call_base< + fusion::unfused_rvalue_args, Function > base; + + typedef typename boost::remove_reference::type function; + typedef typename detail::call_param::type func_const_fwd_t; + + public: + + inline explicit unfused_rvalue_args(func_const_fwd_t f = function()) + : fnc_transformed(f) + { } + + using base::operator(); + + template < + BOOST_PP_ENUM_BINARY_PARAMS( + BOOST_FUSION_UNFUSED_RVALUE_ARGS_MAX_ARITY, + typename T, = fusion::void_ BOOST_PP_INTERCEPT ), + class _ = fusion::void_ > + struct result; + + template + struct result + : base::r0 + { }; + + #define BOOST_PP_FILENAME_1 \ + + #define BOOST_PP_ITERATION_LIMITS \ + (1,BOOST_FUSION_UNFUSED_RVALUE_ARGS_MAX_ARITY) + #include BOOST_PP_ITERATE() + }; +}} + +#define BOOST_FUSION_CLASS_TPL_PARAMS class F +#define BOOST_FUSION_CLASS_TPL_SPEC fusion::unfused_rvalue_args +#define BOOST_FUSION_FUNC_OBJ_ARITY BOOST_FUSION_UNFUSED_RVALUE_ARG_MAX_ARITY +#include + +#define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_RVALUE_ARGS_HPP_INCLUDED +#else // defined(BOOST_PP_IS_ITERATING) +//////////////////////////////////////////////////////////////////////////////// +// +// Preprocessor vertical repetition code +// +//////////////////////////////////////////////////////////////////////////////// +#define N BOOST_PP_ITERATION() + + template + struct result +#if N < BOOST_FUSION_UNFUSED_RVALUE_ARGS_MAX_ARITY + < BOOST_PP_ENUM_PARAMS(N,T), + BOOST_PP_ENUM_PARAMS( + BOOST_PP_SUB(BOOST_FUSION_UNFUSED_RVALUE_ARGS_MAX_ARITY,N), + fusion::void_ BOOST_PP_INTERCEPT), _ > +#endif + : function::template result< BOOST_PP_CAT(fusion::vector,N)< + BOOST_PP_ENUM_BINARY_PARAMS(N,typename detail::cref::type + BOOST_PP_INTERCEPT) > > + { }; + + template + inline typename function::template result >::type + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const& a)) const + { + BOOST_PP_CAT(fusion::vector,N)< + BOOST_PP_ENUM_BINARY_PARAMS(N,T,const& BOOST_PP_INTERCEPT) > + arg(BOOST_PP_ENUM_PARAMS(N,a)); + return this->fnc_transformed(arg); + } + + template + inline typename function::template result >::type + operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const& a)) + { + BOOST_PP_CAT(fusion::vector,N)< + BOOST_PP_ENUM_BINARY_PARAMS(N,T,const& BOOST_PP_INTERCEPT) > + arg(BOOST_PP_ENUM_PARAMS(N,a)); + return this->fnc_transformed(arg); + } + +#undef N +#endif // defined(BOOST_PP_IS_ITERATING) +#endif + diff --git a/include/boost/fusion/functional/adapter/unfused_typed.hpp b/include/boost/fusion/functional/adapter/unfused_typed.hpp new file mode 100644 index 00000000..7eae5d53 --- /dev/null +++ b/include/boost/fusion/functional/adapter/unfused_typed.hpp @@ -0,0 +1,200 @@ +/*============================================================================= + 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_UNFUSED_TYPED_HPP_INCLUDED) +#if !defined(BOOST_PP_IS_ITERATING) + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace boost { namespace fusion +{ + + template class unfused_typed; + + //----- ---- --- -- - - - - + + namespace detail + { + template + struct unfused_typed_impl; + + template ::type > + struct unfused_typed_next_base + { + // type of the next base class + typedef unfused_typed_impl + < Derived, Function, NextSeq, result_of::size::value, + has_type< typename Function::template result< + typename result_of::as_vector::type > >::value + > + type; + }; + + template + struct unfused_typed_impl + : unfused_typed_next_base::type + { }; + + template + struct unfused_typed_impl + : nullary_call_base + { }; + + template + struct unfused_typed_impl + : nullary_call_base + { }; + + } + + template + class unfused_typed + : public detail::unfused_typed_next_base + < unfused_typed, + typename remove_reference::type, Sequence, Sequence + >::type + { + Function fnc_transformed; + + template + friend struct detail::unfused_typed_impl; + + template + friend struct detail::nullary_call_base; + + typedef typename boost::remove_reference::type function; + typedef typename detail::call_param::type func_const_fwd_t; + + typedef typename detail::unfused_typed_next_base,function,Sequence,Sequence>::type base; + + public: + + inline explicit unfused_typed(func_const_fwd_t f = Function()) + : fnc_transformed(f) + { } + + template < + BOOST_PP_ENUM_BINARY_PARAMS(BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY, + typename T, = fusion::void_ BOOST_PP_INTERCEPT), + class _ = fusion::void_ + > + struct result; + + template + struct result< + BOOST_PP_ENUM_PARAMS(BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY, + fusion::void_ BOOST_PP_INTERCEPT),_> + : base::r0 + { }; + }; + + #define BOOST_PP_FILENAME_1 + #define BOOST_PP_ITERATION_LIMITS (1,BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY) + #include BOOST_PP_ITERATE() + +}} + +#define BOOST_FUSION_CLASS_TPL_PARAMS class F, class S +#define BOOST_FUSION_CLASS_TPL_SPEC fusion::unfused_typed +#define BOOST_FUSION_FUNC_OBJ_ARITY BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY +#include + +#define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_TYPED_HPP_INCLUDED +#else // defined(BOOST_PP_IS_ITERATING) +/////////////////////////////////////////////////////////////////////////////// +// +// Preprocessor vertical repetition code +// +/////////////////////////////////////////////////////////////////////////////// +#define N BOOST_PP_ITERATION() + + namespace detail + { + + template + struct unfused_typed_impl + : unfused_typed_next_base::type + { + private: + typedef typename unfused_typed_next_base< + Derived,Function,Sequence>::type base; + + // Notes: + // - conversion to fusion::vector might not be perfect (there is + // currently no "inrinsic converting ctor" that would allow us + // to let the user choose the sequence implementation) + // - value_at_c (instead of iteration) is OK because of conversion + // to fusion::vector - we would need iteration for arbitrary + // sequences + typedef typename result_of::as_vector::type arg_vector_t; + public: + + using base::operator(); + + typedef typename Function:: + template result BOOST_PP_CAT(r,N); + +#define M(z,i,s) \ + typename call_param::type>::type a##i + + inline typename Function::template result::type + operator()(BOOST_PP_ENUM(N,M,arg_vector_t)) const + { + arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a)); + return static_cast(this)->fnc_transformed(arg); + } + + inline typename Function::template result::type + operator()(BOOST_PP_ENUM(N,M,arg_vector_t)) + { + arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a)); + return static_cast(this)->fnc_transformed(arg); + } + +#undef M + }; + + } // namespace detail + + template + template + struct unfused_typed::result +#if N < BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY + < BOOST_PP_ENUM_PARAMS(N,T), + BOOST_PP_ENUM_PARAMS( + BOOST_PP_SUB(BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY,N), + fusion::void_ BOOST_PP_INTERCEPT), _ > +#endif + : BOOST_PP_CAT(base::r,N) + { }; + +#undef N +#endif // defined(BOOST_PP_IS_ITERATING) +#endif + diff --git a/include/boost/fusion/functional/generation.hpp b/include/boost/fusion/functional/generation.hpp new file mode 100644 index 00000000..3dabd3ee --- /dev/null +++ b/include/boost/fusion/functional/generation.hpp @@ -0,0 +1,19 @@ +/*============================================================================= + Copyright (c) 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_GENERATION_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_GENERATION_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include + +#endif diff --git a/include/boost/fusion/functional/generation/detail/gen_make_adapter.hpp b/include/boost/fusion/functional/generation/detail/gen_make_adapter.hpp new file mode 100644 index 00000000..1c2c3e95 --- /dev/null +++ b/include/boost/fusion/functional/generation/detail/gen_make_adapter.hpp @@ -0,0 +1,44 @@ +/*============================================================================= + Copyright (c) 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. + +#include +#include + +#if !defined(BOOST_FUSION_CLASS_TPL_NAME) +# error "BOOST_FUSION_CLASS_TPL_NAME undefined" +#endif + +#define BOOST_FUSION_FUNC_NAME BOOST_PP_CAT(make_,BOOST_FUSION_CLASS_TPL_NAME) + +namespace boost { namespace fusion +{ + + namespace result_of + { + template + struct BOOST_FUSION_FUNC_NAME + { + typedef fusion::BOOST_FUSION_CLASS_TPL_NAME< + typename fusion::detail::as_fusion_element::type > type; + }; + } + + template + inline typename result_of::BOOST_FUSION_FUNC_NAME::type + BOOST_FUSION_FUNC_NAME(F const & f) + { + return typename result_of::BOOST_FUSION_FUNC_NAME::type(f); + } + +}} + +#undef BOOST_FUSION_CLASS_TPL_NAME +#undef BOOST_FUSION_FUNC_NAME + diff --git a/include/boost/fusion/functional/generation/make_fused.hpp b/include/boost/fusion/functional/generation/make_fused.hpp new file mode 100644 index 00000000..12365824 --- /dev/null +++ b/include/boost/fusion/functional/generation/make_fused.hpp @@ -0,0 +1,18 @@ +/*============================================================================= + Copyright (c) 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_GENERATION_MAKE_FUSED_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_GENERATION_MAKE_FUSED_HPP_INCLUDED + +#include + +#define BOOST_FUSION_CLASS_TPL_NAME fused +#include + +#endif + diff --git a/include/boost/fusion/functional/generation/make_fused_function_object.hpp b/include/boost/fusion/functional/generation/make_fused_function_object.hpp new file mode 100644 index 00000000..4146ddd6 --- /dev/null +++ b/include/boost/fusion/functional/generation/make_fused_function_object.hpp @@ -0,0 +1,18 @@ +/*============================================================================= + Copyright (c) 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_GENERATION_MAKE_FUSED_FUNCTION_OBJECT_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_GENERATION_MAKE_FUSED_FUNCTION_OBJECT_HPP_INCLUDED + +#include + +#define BOOST_FUSION_CLASS_TPL_NAME fused_function_object +#include + +#endif + diff --git a/include/boost/fusion/functional/generation/make_fused_procedure.hpp b/include/boost/fusion/functional/generation/make_fused_procedure.hpp new file mode 100644 index 00000000..0687577c --- /dev/null +++ b/include/boost/fusion/functional/generation/make_fused_procedure.hpp @@ -0,0 +1,18 @@ +/*============================================================================= + Copyright (c) 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_GENERATION_MAKE_FUSED_PROCEDURE_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_GENERATION_MAKE_FUSED_PROCEDURE_HPP_INCLUDED + +#include + +#define BOOST_FUSION_CLASS_TPL_NAME fused_procedure +#include + +#endif + diff --git a/include/boost/fusion/functional/generation/make_unfused_generic.hpp b/include/boost/fusion/functional/generation/make_unfused_generic.hpp new file mode 100644 index 00000000..87a99c59 --- /dev/null +++ b/include/boost/fusion/functional/generation/make_unfused_generic.hpp @@ -0,0 +1,18 @@ +/*============================================================================= + Copyright (c) 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_GENERATION_MAKE_UNFUSED_GENERIC_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_GENERATION_MAKE_UNFUSED_GENERIC_HPP_INCLUDED + +#include + +#define BOOST_FUSION_CLASS_TPL_NAME unfused_generic +#include + +#endif + diff --git a/include/boost/fusion/functional/generation/make_unfused_lvalue_args.hpp b/include/boost/fusion/functional/generation/make_unfused_lvalue_args.hpp new file mode 100644 index 00000000..f3c49e45 --- /dev/null +++ b/include/boost/fusion/functional/generation/make_unfused_lvalue_args.hpp @@ -0,0 +1,18 @@ +/*============================================================================= + Copyright (c) 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_GENERATION_MAKE_UNFUSED_LVALUE_ARGS_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_GENERATION_MAKE_UNFUSED_LVALUE_ARGS_HPP_INCLUDED + +#include + +#define BOOST_FUSION_CLASS_TPL_NAME unfused_lvalue_args +#include + +#endif + diff --git a/include/boost/fusion/functional/generation/make_unfused_rvalue_args.hpp b/include/boost/fusion/functional/generation/make_unfused_rvalue_args.hpp new file mode 100644 index 00000000..9322e1e0 --- /dev/null +++ b/include/boost/fusion/functional/generation/make_unfused_rvalue_args.hpp @@ -0,0 +1,18 @@ +/*============================================================================= + Copyright (c) 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_GENERATION_MAKE_UNFUSED_RVALUE_ARGS_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_GENERATION_MAKE_UNFUSED_RVALUE_ARGS_HPP_INCLUDED + +#include + +#define BOOST_FUSION_CLASS_TPL_NAME unfused_rvalue_args +#include + +#endif + diff --git a/include/boost/fusion/functional/invocation.hpp b/include/boost/fusion/functional/invocation.hpp new file mode 100644 index 00000000..3ca68c34 --- /dev/null +++ b/include/boost/fusion/functional/invocation.hpp @@ -0,0 +1,16 @@ +/*============================================================================= + 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_INVOCATION_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_INVOCATION_HPP_INCLUDED + +#include +#include +#include + +#endif diff --git a/include/boost/fusion/functional/invocation/detail/that_ptr.hpp b/include/boost/fusion/functional/invocation/detail/that_ptr.hpp new file mode 100644 index 00000000..a92c436b --- /dev/null +++ b/include/boost/fusion/functional/invocation/detail/that_ptr.hpp @@ -0,0 +1,87 @@ +/*============================================================================= + 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_INVOCATION_DETAIL_THAT_PTR_HPP_INCLUDED) +#define BOOST_FUSION_FUNCTIONAL_INVOCATION_DETAIL_THAT_PTR_HPP_INCLUDED + +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ + template + struct that_ptr + { + private: + + typedef typename remove_reference::type pointee; + + template + static inline pointee * do_get_pointer(T &, pointee * x) + { + return x; + } + template + static inline pointee * do_get_pointer(T & x, void const *) + { + return get_pointer(x); + } + + public: + + static inline pointee * get(pointee * x) + { + return x; + } + + static inline pointee * get(pointee & x) + { + return boost::addressof(x); + } + + template static inline pointee * get(T & x) + { + return do_get_pointer(x, boost::addressof(x)); + } + }; + + template struct non_const_pointee; + + namespace adl_barrier + { + using boost::get_pointer; + void const * BOOST_TT_DECL get_pointer(...); // fallback + + template< typename T> char const_tester(T *); + template< typename T> long const_tester(T const *); + + template + struct non_const_pointee_impl + { + static Ptr & what; + + static bool const value = + sizeof(const_tester(get_pointer(what))) == 1; + }; + } + + template struct non_const_pointee + : adl_barrier::non_const_pointee_impl< + typename remove_cv< + typename remove_reference::type >::type > + { + typedef non_const_pointee type; + typedef bool value_type; + }; + +}}} + +#endif + diff --git a/include/boost/fusion/functional/invocation/invoke.hpp b/include/boost/fusion/functional/invocation/invoke.hpp new file mode 100644 index 00000000..61e09b39 --- /dev/null +++ b/include/boost/fusion/functional/invocation/invoke.hpp @@ -0,0 +1,332 @@ +/*============================================================================= + Copyright (c) 2005-2006 João Abecasis + 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_INVOCATION_INVOKE_HPP_INCLUDED) +#if !defined(BOOST_PP_IS_ITERATING) + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template struct invoke; + } + + template + inline typename result_of::invoke::type + invoke(Function, Sequence &); + + template + inline typename result_of::invoke::type + invoke(Function, Sequence const &); + + //----- ---- --- -- - - - - + + namespace detail + { + namespace ft = function_types; + + template< + typename Function, class Sequence, + int N = result_of::size::value, + bool CBI = ft::is_callable_builtin::value, + bool MFP = ft::is_member_function_pointer::value, + bool RandomAccess = boost::is_convertible< + typename traits::category_of::type, + fusion::random_access_traversal_tag + >::value + > + struct invoke_impl + { + typedef boost::blank result; + }; + + template struct invoke_param_types; + + template + // contains type member with the result, empty on error + struct invoke_result + : mpl::if_< + mpl::or_< + mpl::equal_to< ft::function_arity, N >, + mpl::and_< ft::is_callable_builtin, + mpl::less< ft::function_arity, N > > + >, ft::result_type, boost::blank + >::type + { }; + template + struct invoke_result + : boost::result_of + { }; + + // Transform for F so that boost::result_of< F(...) > works + template struct invoke_result_of_prep + : mpl::if_< ft::is_function, boost::add_reference, + boost::remove_cv + >::type + { }; + + #define BOOST_PP_FILENAME_1 + #define BOOST_PP_ITERATION_LIMITS (0, BOOST_FUSION_INVOKE_MAX_ARITY) + #include BOOST_PP_ITERATE() + + template + struct invoke_data_member + { + private: + + typedef typename result_of::front::type that; + + typedef mpl::or_< is_convertible, + is_convertible, + non_const_pointee > non_const_cond; + + typedef typename mpl::eval_if< non_const_cond, + mpl::identity, add_const >::type qualified_class; + + typedef typename mpl::eval_if< non_const_cond, + mpl::identity, add_const >::type qualified_type; + + public: + + template + struct result + : boost::add_reference + { }; + + static inline typename result<>::type call(T C::* f, Sequence & s) + { + typename result_of::front::type c = fusion::front(s); + return that_ptr::get(c)->*f; + } + }; + + template + struct invoke_impl + : detail::invoke_data_member + { }; + + template + struct invoke_impl + : detail::invoke_data_member + { }; + + } + + namespace result_of + { + template struct invoke + : detail::invoke_impl< + typename boost::remove_reference::type, Sequence + >::template result<> + { }; + } + + template + inline typename result_of::invoke::type + invoke(Function f, Sequence & s) + { + return detail::invoke_impl< + typename boost::remove_reference::type,Sequence + >::call(f,s); + } + + template + inline typename result_of::invoke::type + invoke(Function f, Sequence const & s) + { + return detail::invoke_impl< + typename boost::remove_reference::type,Sequence const + >::call(f,s); + } + +}} + +#define BOOST_FUSION_FUNCTIONAL_INVOCATION_INVOKE_HPP_INCLUDED +#else // defined(BOOST_PP_IS_ITERATING) +/////////////////////////////////////////////////////////////////////////////// +// +// Preprocessor vertical repetition code +// +/////////////////////////////////////////////////////////////////////////////// +#define N BOOST_PP_ITERATION() + + template + struct invoke_impl + { + private: + typedef typename invoke_result_of_prep::type func; + public: + + template + struct result + : invoke_result< Function, mpl::size_t, CBI, +#define M(z,j,data) typename result_of::at_c::type + func(BOOST_PP_ENUM(N,M,~)) > +#undef M + { }; + + template + static inline typename result::type + call(F & f, Sequence & s) + { +#define M(z,j,data) fusion::at_c(s) + return f( BOOST_PP_ENUM(N,M,~) ); + } + }; + +#if N > 0 + template + struct invoke_impl + { + public: + + template + struct result + : invoke_result< Function, mpl::size_t > + { }; + + template + static inline typename result::type + call(F & f, Sequence & s) + { + return (that_ptr >::type + >::get(fusion::at_c<0>(s))->*f)(BOOST_PP_ENUM_SHIFTED(N,M,~)); + } + }; +#endif + +#undef M + +#define M(z,j,data) \ + typename seq::I##j i##j = \ + fusion::next(BOOST_PP_CAT(i,BOOST_PP_DEC(j))); + + template + struct invoke_impl + { + private: + typedef typename invoke_result_of_prep::type func; + typedef invoke_param_types seq; + public: + + template + struct result + : invoke_result< Function, mpl::size_t, CBI, + func(BOOST_PP_ENUM_PARAMS(N,typename seq::T)) > + { }; + + template + static inline typename result::type + call(F & f, Sequence & s) + { +#if N > 0 + typename seq::I0 i0 = fusion::begin(s); + BOOST_PP_REPEAT_FROM_TO(1,N,M,~) +#endif + return f( BOOST_PP_ENUM_PARAMS(N,*i) ); + } + }; + +#if N > 0 + template + struct invoke_impl + { + private: + typedef invoke_param_types seq; + public: + + template + struct result + : invoke_result< Function, mpl::size_t > + { }; + + template + static inline typename result::type + call(F & f, Sequence & s) + { + typename seq::I0 i0 = fusion::begin(s); + BOOST_PP_REPEAT_FROM_TO(1,N,M,~) + + return (that_ptr< typename mpl::front< + ft::parameter_types >::type + >::get(*i0)->*f)(BOOST_PP_ENUM_SHIFTED_PARAMS(N,*i)); + } + }; +#endif + +#undef M + + template struct invoke_param_types + { +#if N > 0 + typedef typename result_of::begin::type I0; + typedef typename result_of::deref::type T0; + +#define M(z,i,data) \ + typedef typename result_of::next< \ + BOOST_PP_CAT(I,BOOST_PP_DEC(i))>::type I##i; \ + typedef typename result_of::deref::type T##i; + + BOOST_PP_REPEAT_FROM_TO(1,N,M,~) +#undef M +#endif + }; + + +#undef N +#endif // defined(BOOST_PP_IS_ITERATING) +#endif + diff --git a/include/boost/fusion/functional/invocation/invoke_function_object.hpp b/include/boost/fusion/functional/invocation/invoke_function_object.hpp new file mode 100644 index 00000000..92908b99 --- /dev/null +++ b/include/boost/fusion/functional/invocation/invoke_function_object.hpp @@ -0,0 +1,190 @@ +/*============================================================================= + Copyright (c) 2005-2006 João Abecasis + 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_INVOCATION_INVOKE_FUNCTION_OBJECT_HPP_INCLUDED) +#if !defined(BOOST_PP_IS_ITERATING) + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template struct invoke_function_object; + } + + template + inline typename result_of::invoke_function_object::type + invoke_function_object(Function, Sequence &); + + template + inline typename result_of::invoke_function_object::type invoke_function_object(Function, Sequence const &); + + //----- ---- --- -- - - - - + + namespace detail + { + template< + class Function, class Sequence, + int N = result_of::size::value, + bool RandomAccess = boost::is_convertible< + typename traits::category_of::type, + fusion::random_access_traversal_tag + >::value + > + struct invoke_function_object_impl + { + typedef boost::blank result; + }; + + template + struct invoke_function_object_param_types; + + #define BOOST_PP_FILENAME_1 \ + + #define BOOST_PP_ITERATION_LIMITS \ + (0, BOOST_FUSION_INVOKE_FUNCTION_OBJECT_MAX_ARITY) + #include BOOST_PP_ITERATE() + } + + namespace result_of + { + template struct invoke_function_object + : detail::invoke_function_object_impl< + typename boost::remove_reference::type, Sequence + >::template result<> + { }; + } + + template + inline typename result_of::invoke_function_object::type + invoke_function_object(Function f, Sequence & s) + { + return detail::invoke_function_object_impl< + typename boost::remove_reference::type,Sequence + >::call(f,s); + } + + template + inline typename result_of::invoke_function_object::type + invoke_function_object(Function f, Sequence const & s) + { + return detail::invoke_function_object_impl< + typename boost::remove_reference::type,Sequence const + >::call(f,s); + } + +}} + +#define BOOST_FUSION_FUNCTIONAL_INVOCATION_INVOKE_FUNCTION_OBJECT_HPP_INCLUDED +#else // defined(BOOST_PP_IS_ITERATING) +/////////////////////////////////////////////////////////////////////////////// +// +// Preprocessor vertical repetition code +// +/////////////////////////////////////////////////////////////////////////////// +#define N BOOST_PP_ITERATION() + + template + struct invoke_function_object_impl + { + public: + + template + struct result + : Function::template result < +#define M(z,j,data) \ + typename boost::remove_reference< \ + typename result_of::value_at_c::type >::type + BOOST_PP_ENUM(N,M,~) > +#undef M + { }; + + template + static inline typename result::type + call(F & f, Sequence & s) + { +#define M(z,j,data) fusion::at_c(s) + return f( BOOST_PP_ENUM(N,M,~) ); +#undef M + } + }; + + template + struct invoke_function_object_impl + { + private: + typedef invoke_function_object_param_types seq; + public: + + template + struct result + : Function::template result < + BOOST_PP_ENUM_PARAMS(N,typename seq::T) > + { }; + + template + static inline typename result::type + call(F & f, Sequence & s) + { +#if N > 0 + typename seq::I0 i0 = fusion::begin(s); +#define M(z,j,data) \ + typename seq::I##j i##j = \ + fusion::next(BOOST_PP_CAT(i,BOOST_PP_DEC(j))); + BOOST_PP_REPEAT_FROM_TO(1,N,M,~) +#undef M +#endif + return f( BOOST_PP_ENUM_PARAMS(N,*i) ); + } + }; + + template + struct invoke_function_object_param_types + { +#if N > 0 + typedef typename result_of::begin::type I0; + typedef typename boost::remove_reference< + typename result_of::value_of::type >::type T0; + +#define M(z,i,data) \ + typedef typename result_of::next< \ + BOOST_PP_CAT(I,BOOST_PP_DEC(i))>::type I##i; \ + typedef typename boost::remove_reference< \ + typename result_of::value_of::type >::type T##i; + + BOOST_PP_REPEAT_FROM_TO(1,N,M,~) +#undef M +#endif + }; + +#undef N +#endif // defined(BOOST_PP_IS_ITERATING) +#endif + diff --git a/include/boost/fusion/functional/invocation/invoke_procedure.hpp b/include/boost/fusion/functional/invocation/invoke_procedure.hpp new file mode 100644 index 00000000..db0b029e --- /dev/null +++ b/include/boost/fusion/functional/invocation/invoke_procedure.hpp @@ -0,0 +1,225 @@ +/*============================================================================= + Copyright (c) 2005-2006 João Abecasis + 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_INVOCATION_INVOKE_PROCEDURE_HPP_INCLUDED) +#if !defined(BOOST_PP_IS_ITERATING) + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template struct invoke_procedure; + } + + template + inline void invoke_procedure(Function, Sequence &); + + template + inline void invoke_procedure(Function, Sequence const &); + + //----- ---- --- -- - - - - + + namespace detail + { + namespace ft = function_types; + + template< + typename Function, class Sequence, + int N = result_of::size::value, + bool CBI = ft::is_callable_builtin::value, + bool MFP = ft::is_member_function_pointer::value, + bool RandomAccess = boost::is_convertible< + typename traits::category_of::type, + fusion::random_access_traversal_tag + >::value + > + struct invoke_procedure_impl + { + typedef boost::blank result; + }; + + template + // Contains void type member, empty on arity mismatch + struct invoke_procedure_result + : mpl::if_< + mpl::or_< + mpl::bool_, + mpl::equal_to< ft::function_arity, N >, + mpl::and_< ft::is_callable_builtin, + mpl::less< ft::function_arity, N > > + >, mpl::identity, boost::blank + >::type + { }; + + #define BOOST_PP_FILENAME_1 \ + + #define BOOST_PP_ITERATION_LIMITS \ + (0, BOOST_FUSION_INVOKE_PROCEDURE_MAX_ARITY) + #include BOOST_PP_ITERATE() + + } + + namespace result_of + { + template struct invoke_procedure + : detail::invoke_procedure_impl< + typename boost::remove_reference::type, Sequence + >::result + { }; + } + + template + inline void invoke_procedure(Function f, Sequence & s) + { + detail::invoke_procedure_impl< + typename boost::remove_reference::type,Sequence + >::call(f,s); + } + + template + inline void invoke_procedure(Function f, Sequence const & s) + { + detail::invoke_procedure_impl< + typename boost::remove_reference::type,Sequence const + >::call(f,s); + } + +}} + +#define BOOST_FUSION_FUNCTIONAL_INVOCATION_INVOKE_PROCEDURE_HPP_INCLUDED +#else // defined(BOOST_PP_IS_ITERATING) +/////////////////////////////////////////////////////////////////////////////// +// +// Preprocessor vertical repetition code +// +/////////////////////////////////////////////////////////////////////////////// +#define N BOOST_PP_ITERATION() + +#define M(z,j,data) fusion::at_c(s) + + template + struct invoke_procedure_impl + { + struct result + : invoke_procedure_result< Function, mpl::size_t, CBI > + { }; + + static inline void call(Function & f, Sequence & s) + { + f(BOOST_PP_ENUM(N,M,~)); + } + }; + +#if N > 0 + template + struct invoke_procedure_impl + { + struct result + : invoke_procedure_result< Function, mpl::size_t > + { }; + + static inline void call(Function & f, Sequence & s) + { + (that_ptr >::type + >::get(fusion::at_c<0>(s))->*f)(BOOST_PP_ENUM_SHIFTED(N,M,~)); + } + }; +#endif + +#undef M + +#define M(z,j,data) \ + typedef typename result_of::next< BOOST_PP_CAT(I,BOOST_PP_DEC(j)) \ + >::type I ## j ; \ + I##j i##j = fusion::next(BOOST_PP_CAT(i,BOOST_PP_DEC(j))); + + template + struct invoke_procedure_impl + { + struct result + : invoke_procedure_result< Function, mpl::size_t, CBI > + { }; + + static inline void call(Function & f, Sequence & s) + { +#if N > 0 + typedef typename result_of::begin::type I0; + I0 i0 = fusion::begin(s); + BOOST_PP_REPEAT_FROM_TO(1,N,M,~) +#endif + f( BOOST_PP_ENUM_PARAMS(N,*i) ); + } + }; + +#if N > 0 + template + struct invoke_procedure_impl + { + struct result + : invoke_procedure_result< Function, mpl::size_t > + { }; + + static inline void call(Function & f, Sequence & s) + { + typedef typename result_of::begin::type I0; + I0 i0 = fusion::begin(s); + BOOST_PP_REPEAT_FROM_TO(1,N,M,~) + + (that_ptr >::type + >::get(*i0)->*f)(BOOST_PP_ENUM_SHIFTED_PARAMS(N,*i)); + } + }; +#endif + +#undef M + +#undef N +#endif // defined(BOOST_PP_IS_ITERATING) +#endif + diff --git a/include/boost/fusion/functional/invocation/limits.hpp b/include/boost/fusion/functional/invocation/limits.hpp new file mode 100644 index 00000000..9cb5a04a --- /dev/null +++ b/include/boost/fusion/functional/invocation/limits.hpp @@ -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). +==============================================================================*/ + +#if !defined(BOOST_FUSION_FUNCTIONAL_INVOCATION_LIMITS_HPP_INCLUDED) +# define BOOST_FUSION_FUNCTIONAL_INVOCATION_LIMITS_HPP_INCLUDED + +# if !defined(BOOST_FUSION_INVOKE_MAX_ARITY) +# define BOOST_FUSION_INVOKE_MAX_ARITY 6 +# endif +# if !defined(BOOST_FUSION_INVOKE_PROCEDURE_MAX_ARITY) +# define BOOST_FUSION_INVOKE_PROCEDURE_MAX_ARITY 6 +# endif +# if !defined(BOOST_FUSION_INVOKE_FUNCTION_OBJECT_MAX_ARITY) +# define BOOST_FUSION_INVOKE_FUNCTION_OBJECT_MAX_ARITY 6 +# endif + +#endif +