|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55779 - in sandbox/SOC/2009/fusion: . boost/fusion/algorithm/iteration/detail boost/fusion/functional/invocation/detail/0x boost/fusion/support boost/fusion/support/internal boost/fusion/view/detail libs/fusion/test/compile_time
From: mr.chr.schmidt_at_[hidden]
Date: 2009-08-25 16:52:52
Author: cschmidt
Date: 2009-08-25 16:52:51 EDT (Tue, 25 Aug 2009)
New Revision: 55779
URL: http://svn.boost.org/trac/boost/changeset/55779
Log:
optimizations
Text files modified:
sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/fold.hpp | 142 +++++++++++++++++++++++----------------
sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/for_each.hpp | 13 +--
sandbox/SOC/2009/fusion/boost/fusion/functional/invocation/detail/0x/invoke_impl_detail.hpp | 20 +++-
sandbox/SOC/2009/fusion/boost/fusion/support/deduce.hpp | 2
sandbox/SOC/2009/fusion/boost/fusion/support/internal/ref.hpp | 2
sandbox/SOC/2009/fusion/boost/fusion/support/internal/result_of.hpp | 114 +++++++++++++++++++------------
sandbox/SOC/2009/fusion/boost/fusion/view/detail/view_storage.hpp | 14 +-
sandbox/SOC/2009/fusion/libs/fusion/test/compile_time/fold.cpp | 11 +++
sandbox/SOC/2009/fusion/project-root.jam | 6
9 files changed, 191 insertions(+), 133 deletions(-)
Modified: sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/fold.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/fold.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/fold.hpp 2009-08-25 16:52:51 EDT (Tue, 25 Aug 2009)
@@ -22,9 +22,9 @@
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp>
-#include <boost/mpl/apply.hpp>
-#include <boost/mpl/identity.hpp>
-#include <boost/type_traits/add_const.hpp>
+#ifdef BOOST_NO_RVALUE_REFERENCES
+# include <boost/type_traits/add_const.hpp>
+#endif
namespace boost { namespace fusion { namespace detail
{
@@ -124,105 +124,127 @@
}
};
- template <typename It, typename StateRef, typename FRef>
+ template <typename It, typename StateRef, typename F>
struct fold_apply
{
- typedef typename result_of::deref<It>::type deref_type;
-
-#ifdef BOOST_NO_RVALUE_REFERENCES
- typedef typename
- boost::result_of<
- typename get_func_base<FRef>::type(deref_type, StateRef)
- >::type
- type;
-#else
typedef typename
boost::result_of<
- typename get_func_base<FRef>::type(
- typename mpl::if_<
- is_lrref<deref_type>
- , deref_type
- , deref_type&&
+ F(
+#ifdef BOOST_NO_RVALUE_REFERENCES
+ typename add_lref<
+ typename add_const<
+ typename result_of::deref<It>::type
+ >::type
>::type
- , StateRef
- )
+#else
+ typename result_of::deref<It>::type&&
+#endif
+ , StateRef)
>::type
type;
-#endif
};
- template <typename It, typename State, typename FRef>
- struct fold_apply_r_else_clref
-#ifdef BOOST_NO_RVALUE_REFERENCES
+ template <typename It, typename State, typename F>
+ struct fold_apply_rvalue_state
: fold_apply<
It
+#ifdef BOOST_NO_RVALUE_REFERENCES
, typename add_lref<typename add_const<State>::type>::type
- , FRef
- >
#else
- : fold_apply<It,State&&,FRef>
+ , State&&
#endif
+ , F
+ >
{};
- template<typename It0, typename StateRef, typename FRef, int N>
+ template<typename It0, typename StateRef, typename F, int N>
struct result_of_unrolled_fold
{
- typedef typename fold_apply<It0, StateRef, FRef>::type rest1;
+ typedef typename fold_apply_rvalue_state<It0, StateRef, F>::type rest1;
typedef typename result_of::next<It0>::type it1;
- typedef typename fold_apply_r_else_clref<it1, rest1, FRef>::type rest2;
+ typedef typename fold_apply_rvalue_state<it1, rest1, F>::type rest2;
typedef typename result_of::next<it1>::type it2;
- typedef typename fold_apply_r_else_clref<it2, rest2, FRef>::type rest3;
+ typedef typename fold_apply_rvalue_state<it2, rest2, F>::type rest3;
typedef typename result_of::next<it2>::type it3;
- typedef typename fold_apply_r_else_clref<it3, rest3, FRef>::type rest4;
- typedef typename result_of::next<it3>::type it4;
typedef typename
- mpl::eval_if_c<
- !(N-4)
- , mpl::identity<rest4>
- , result_of_unrolled_fold<
- it4
- , BOOST_FUSION_R_ELSE_CLREF(rest4)
- , FRef
- , N-4
- >
+ result_of_unrolled_fold<
+ typename result_of::next<it3>::type
+ , typename fold_apply_rvalue_state<it3, rest3, F>::type
+ , F
+ , N-4
>::type
type;
};
- template<typename It0, typename StateRef, typename FRef>
- struct result_of_unrolled_fold<It0, StateRef, FRef, 3>
+ template<typename It0, typename StateRef, typename F>
+ struct result_of_unrolled_fold<It0, StateRef, F, 3>
{
- typedef typename fold_apply<It0, StateRef, FRef>::type rest1;
+ typedef typename fold_apply_rvalue_state<It0, StateRef, F>::type rest1;
typedef typename result_of::next<It0>::type it1;
- typedef typename fold_apply_r_else_clref<it1, rest1, FRef>::type rest2;
- typedef typename result_of::next<it1>::type it2;
- typedef typename fold_apply_r_else_clref<it2, rest2, FRef>::type type;
+ typedef typename
+ fold_apply_rvalue_state<
+ typename result_of::next<it1>::type
+ , typename fold_apply_rvalue_state<it1, rest1, F>::type
+ , F
+ >::type
+ type;
};
- template<typename It0, typename StateRef, typename FRef>
- struct result_of_unrolled_fold<It0, StateRef, FRef, 2>
+ template<typename It0, typename StateRef, typename F>
+ struct result_of_unrolled_fold<It0, StateRef, F, 2>
{
- typedef typename fold_apply<It0, StateRef, FRef>::type rest;
- typedef typename result_of::next<It0>::type it1;
-
- typedef typename fold_apply_r_else_clref<it1, rest, FRef>::type type;
+ typedef typename
+ fold_apply_rvalue_state<
+ typename result_of::next<It0>::type
+ , typename fold_apply_rvalue_state<It0, StateRef, F>::type
+ , F
+ >::type
+ type;
};
- template<typename It0, typename StateRef, typename FRef>
- struct result_of_unrolled_fold<It0, StateRef, FRef, 1>
- : fold_apply_r_else_clref<It0, StateRef, FRef>
+ template<typename It0, typename StateRef, typename F>
+ struct result_of_unrolled_fold<It0, StateRef, F, 1>
+ : fold_apply_rvalue_state<It0, StateRef, F>
{};
+ template<typename It0, typename StateRef, typename F>
+ struct result_of_unrolled_fold<It0, StateRef, F, 0>
+ {
+ typedef StateRef type;
+ };
+
+ template<typename It0, typename StateRef, typename FRef, int SeqSize>
+ struct result_of_unrolled_fold_first
+ {
+ typedef typename get_func_base<FRef>::type f;
+
+ typedef typename
+ result_of_unrolled_fold<
+ typename result_of::next<It0>::type
+ , typename fold_apply<It0, StateRef, f>::type
+ , f
+ , SeqSize-1
+ >::type
+ type;
+ };
+
template<int SeqSize, typename It0, typename StateRef, typename FRef>
struct fold_impl
{
+ typedef preevaluate<FRef> preevaluater;
+
typedef typename
mpl::eval_if<
- typename is_preevaluable<FRef>::type
- , preevaluate<FRef>
- , result_of_unrolled_fold<It0, StateRef, FRef, SeqSize>
+ typename preevaluater::is_preevaluable
+ , preevaluater
+ , result_of_unrolled_fold_first<
+ It0
+ , StateRef
+ , FRef
+ , SeqSize
+ >
>::type
type;
Modified: sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/for_each.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/for_each.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/algorithm/iteration/detail/for_each.hpp 2009-08-25 16:52:51 EDT (Tue, 25 Aug 2009)
@@ -39,8 +39,8 @@
f(fusion::deref(it3));
for_each_unrolled<N-4>::call(
- fusion::next(it3)
- , BOOST_FUSION_FORWARD(F,f));
+ fusion::next(it3),
+ BOOST_FUSION_FORWARD(F,f));
}
};
@@ -52,12 +52,10 @@
{
typedef typename result_of::next<It0 const&>::type It1;
It1 it1(fusion::next(it0));
- typedef typename result_of::next<It1&>::type It2;
- It2 it2(fusion::next(it1));
f(fusion::deref(it0));
f(fusion::deref(it1));
- f(fusion::deref(it2));
+ f(fusion::deref(fusion::next(it1)));
}
};
@@ -67,11 +65,8 @@
template<typename It0, typename F>
static void call(It0 const& it0, BOOST_FUSION_R_ELSE_CLREF(F) f)
{
- typedef typename result_of::next<It0 const&>::type It1;
- It1 it1(fusion::next(it0));
-
f(fusion::deref(it0));
- f(fusion::deref(it1));
+ f(fusion::deref(fusion::next(it0)));
}
};
Modified: sandbox/SOC/2009/fusion/boost/fusion/functional/invocation/detail/0x/invoke_impl_detail.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/functional/invocation/detail/0x/invoke_impl_detail.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/functional/invocation/detail/0x/invoke_impl_detail.hpp 2009-08-25 16:52:51 EDT (Tue, 25 Aug 2009)
@@ -70,9 +70,13 @@
>::type
invoke_impl_call(F&& f, ClassInstance&& instance,Args&&... args)
{
- return (that_ptr<typename detail::preevaluate<F>::class_type>::
+ typedef typename
+ detail::preevaluate<F>::gen::class_type
+ class_type;
+
+ return (that_ptr<class_type>::
get(std::forward<ClassInstance>(instance))->*f)(
- std::forward<Args>(args)...);
+ std::forward<Args>(args)...);
}
namespace bidirectional_traversal
@@ -106,10 +110,12 @@
template<typename FRef,typename SeqRef>
struct invoke_impl
{
+ typedef detail::preevaluate<FRef> preevaluater;
+
typedef typename
mpl::eval_if<
- typename detail::is_preevaluable<FRef>::type
- , detail::preevaluate<FRef>
+ typename preevaluater::is_preevaluable
+ , preevaluater
, invoke_impl_result<
FRef
, SeqRef
@@ -185,10 +191,12 @@
template<typename FRef,typename SeqRef>
struct invoke_impl
{
+ typedef detail::preevaluate<FRef> preevaluater;
+
typedef typename
mpl::eval_if<
- typename detail::is_preevaluable<FRef>::type
- , detail::preevaluate<FRef>
+ typename preevaluater::is_preevaluable
+ , preevaluater
, invoke_impl_result<
FRef
, SeqRef
Modified: sandbox/SOC/2009/fusion/boost/fusion/support/deduce.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/support/deduce.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/support/deduce.hpp 2009-08-25 16:52:51 EDT (Tue, 25 Aug 2009)
@@ -44,7 +44,7 @@
\
typedef typename\
mpl::eval_if<\
- is_po_callable\
+ typename is_po_callable::type\
, mpl::if_<\
typename is_po_callable::is_pointer\
, T\
Modified: sandbox/SOC/2009/fusion/boost/fusion/support/internal/ref.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/support/internal/ref.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/support/internal/ref.hpp 2009-08-25 16:52:51 EDT (Tue, 25 Aug 2009)
@@ -182,7 +182,7 @@
mpl::eval_if<
is_rref<TestType>
, mpl::identity<cv_type&&>
- , detail::add_lref<cv_type>
+ , add_lref<cv_type>
>,
mpl::identity<cv_type>
>::type
Modified: sandbox/SOC/2009/fusion/boost/fusion/support/internal/result_of.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/support/internal/result_of.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/support/internal/result_of.hpp 2009-08-25 16:52:51 EDT (Tue, 25 Aug 2009)
@@ -12,8 +12,20 @@
//Therefore we emulate the old behavior if (and only if) the boost
//implementation falls back to decltype by default.
+#include <boost/config.hpp>
#include <boost/fusion/support/internal/ref.hpp>
+#if defined(BOOST_NO_DECLTYPE) || !defined(BOOST_NO_VARIADIC_TEMPLATES)
+# include <boost/mpl/bool.hpp>
+#endif
+#ifdef BOOST_NO_DECLTYPE
+# include <boost/mpl/has_xxx.hpp>
+# include <boost/mpl/eval_if.hpp>
+# include <boost/mpl/identity.hpp>
+#endif
+#ifndef BOOST_NO_VARIADIC_TEMPLATES
+# include <boost/mpl/identity.hpp>
+#endif
#include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/type_traits/is_pointer.hpp>
@@ -24,7 +36,7 @@
namespace boost { namespace fusion { namespace detail
{
- //cschmidt: These metafunction needs to handle
+ //cschmidt: This metafunction needs to handle
//T()
//T(&)()
//T(cv&)()
@@ -46,47 +58,56 @@
//& -> &&
template<typename FRef>
- struct is_po_callable_impl
+ struct is_po_callable
{
- typedef typename detail::identity<FRef>::type f;
- typedef typename is_pointer<f>::type is_pointer;
+ typedef typename identity<FRef>::type identity_f;
+ typedef typename is_pointer<identity_f>::type is_pointer;
+ typedef typename remove_pointer<identity_f>::type f;
typedef
mpl::or_<
- is_function<typename remove_pointer<f>::type>
+ is_function<f>
, is_member_function_pointer<f>
>
type;
};
- template<typename FRef>
- struct is_po_callable
- : is_po_callable_impl<FRef>::type
+#ifdef BOOST_NO_DECLTYPE
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type);
+
+ template<typename F>
+ struct get_result_type
{
- typedef typename is_po_callable_impl<FRef>::is_pointer is_pointer;
+ typedef typename F::result_type type;
};
-//cschmidt: a pp implementation won't be worth the effort
-#ifdef BOOST_NO_VARIADIC_TEMPLATES
- template<typename FRef>
- struct is_preevaluable
- : mpl::false_
- {};
-
- template<typename FRef>
- struct preevaluate;
+ template<typename F>
+ struct preevaluate_impl
+ {
+ typedef typename has_result_type<F>::type is_preevaluable;
+ typedef typename
+ mpl::eval_if<
+ is_preevaluable
+ , get_result_type<F>
+ , mpl::identity<void>
+ >::type
+ type;
+ };
#else
- template<typename FRef>
- struct is_preevaluable
- : is_po_callable<FRef>
- {};
-
- template<typename FRef>
- struct preevaluate_impl;
+ template<typename F>
+ struct preevaluate_impl
+ {
+ typedef mpl::false_ is_preevaluable;
+ typedef void type;
+ };
+#endif
+ //cschmidt: a pp implementation won't be worth the effort
+#ifndef BOOST_NO_VARIADIC_TEMPLATES
template<typename Result,typename... Args>
struct preevaluate_impl<Result (Args...)>
{
+ typedef mpl::true_ is_preevaluable;
typedef Result type;
};
@@ -95,6 +116,7 @@
{
typedef Class& class_type;
+ typedef mpl::true_ is_preevaluable;
typedef Result type;
};
@@ -105,7 +127,7 @@
struct preevaluate_impl<Result(Class::*)(Args...) const>
{
typedef Class const& class_type;
-
+ typedef mpl::true_ is_preevaluable;
typedef Result type;
};
@@ -113,7 +135,7 @@
struct preevaluate_impl<Result(Class::*)(Args...) const volatile>
{
typedef Class const volatile& class_type;
-
+ typedef mpl::true_ is_preevaluable;
typedef Result type;
};
@@ -121,39 +143,39 @@
struct preevaluate_impl<Result(Class::*)(Args...) volatile>
{
typedef Class volatile& class_type;
-
+ typedef mpl::true_ is_preevaluable;
typedef Result type;
};
+#endif
template<typename FRef>
struct preevaluate
- : preevaluate_impl<
- typename remove_pointer<
- typename detail::identity<FRef>::type
- >::type
- >
- {};
+ {
+#if defined(BOOST_NO_VARIADIC_TEMPLATES) && !defined(BOOST_NO_DECLTYPE)
+ typedef mpl::false_ is_preevaluable;
+#else
+ typedef
+ preevaluate_impl<
+ typename remove_pointer<typename identity<FRef>::type>::type
+ >
+ impl;
+
+ typedef impl gen;
+ typedef typename impl::type type;
+ typedef typename impl::is_preevaluable is_preevaluable;
#endif
+ };
- //cschmidt: The non-decltype result_of does not like ref-qualified
+ //cschmidt: Result_of does not like ref-qualified
//'class type' functions
template<typename FRef>
struct get_func_base
{
typedef typename
- remove_pointer<
- typename detail::identity<FRef>::type
- >::type
- f;
-
- typedef typename
mpl::if_<
- mpl::or_<
- typename is_function<f>::type
- , typename is_member_function_pointer<f>::type
- >
+ typename is_po_callable<FRef>::type
, FRef
- , f
+ , typename is_po_callable<FRef>::f
>::type
type;
};
Modified: sandbox/SOC/2009/fusion/boost/fusion/view/detail/view_storage.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/view/detail/view_storage.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/view/detail/view_storage.hpp 2009-08-25 16:52:51 EDT (Tue, 25 Aug 2009)
@@ -31,7 +31,7 @@
}
template<typename OtherT>
- static typename detail::remove_reference<OtherT>::type*
+ static typename remove_reference<OtherT>::type*
get_init_type(BOOST_FUSION_R_ELSE_LREF(OtherT) other_t, mpl::false_)
{
return &other_t;
@@ -41,8 +41,8 @@
typedef typename
mpl::if_<
traits::is_view<T>
- , typename detail::remove_reference<T>::type
- , typename detail::add_lref<T>::type
+ , typename remove_reference<T>::type
+ , typename add_lref<T>::type
>::type
type;
@@ -50,7 +50,7 @@
typedef typename
mpl::if_<
traits::is_view<T>
- , typename detail::add_lref<typename add_const<T>::type>::type
+ , typename add_lref<typename add_const<T>::type>::type
, type
>::type
call_param;
@@ -89,7 +89,7 @@
typename mpl::if_<
traits::is_view<T>
- , typename detail::add_lref<type>::type
+ , typename add_lref<type>::type
, type
>::type
get() const
@@ -98,7 +98,7 @@
}
private:
- typename detail::add_lref<type>::type
+ typename add_lref<type>::type
get(mpl::true_ /*is_view*/)const
{
return t;
@@ -110,7 +110,7 @@
return *t;
}
- typedef typename detail::remove_reference<T>::type non_ref_t;
+ typedef typename remove_reference<T>::type non_ref_t;
mutable typename
mpl::if_<
traits::is_view<T>
Modified: sandbox/SOC/2009/fusion/libs/fusion/test/compile_time/fold.cpp
==============================================================================
--- sandbox/SOC/2009/fusion/libs/fusion/test/compile_time/fold.cpp (original)
+++ sandbox/SOC/2009/fusion/libs/fusion/test/compile_time/fold.cpp 2009-08-25 16:52:51 EDT (Tue, 25 Aug 2009)
@@ -19,7 +19,18 @@
struct f
{
+#ifdef NO_PREEVALUATE
+ template<typename Sig>
+ struct result;
+
+ template<typename Self, typename D, typename State>
+ struct result<Self(D,State)>
+ {
+ typedef int type;
+ };
+#else
typedef int result_type;
+#endif
template<int n, int batch>
int operator()(distinct<n, batch> const& d, int state) const
Modified: sandbox/SOC/2009/fusion/project-root.jam
==============================================================================
--- sandbox/SOC/2009/fusion/project-root.jam (original)
+++ sandbox/SOC/2009/fusion/project-root.jam 2009-08-25 16:52:51 EDT (Tue, 25 Aug 2009)
@@ -14,14 +14,14 @@
<include>$(BOOST_INCLUDES_PATH)
<define>BOOST_FUSION_ENABLE_STATIC_ASSERTS
<define>BOOST_FUSION_PREFER_MPL
- <toolset>gcc:<cxxflags>-std=c++0x
+# <toolset>gcc:<cxxflags>-std=c++0x
: build-dir ../bin
: default-build debug <link>shared <runtime-link>shared <threading>multi
;
build-project libs/fusion/example/test ;
-build-project libs/fusion/doc ;
+#build-project libs/fusion/doc ;
#build-project libs/fusion/example/extension ;
-build-project libs/fusion/example/performance ;
+#build-project libs/fusion/example/performance ;
build-project libs/fusion/test ;
\ No newline at end of file
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk