Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56030 - in sandbox/SOC/2009/fusion: . boost/fusion/algorithm/query boost/fusion/algorithm/transformation boost/fusion/algorithm/transformation/detail boost/fusion/support libs/fusion/example/test
From: mr.chr.schmidt_at_[hidden]
Date: 2009-09-05 07:08:35


Author: cschmidt
Date: 2009-09-05 07:08:33 EDT (Sat, 05 Sep 2009)
New Revision: 56030
URL: http://svn.boost.org/trac/boost/changeset/56030

Log:
improved replace_if
Text files modified:
   sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/find_key.hpp | 1 +
   sandbox/SOC/2009/fusion/boost/fusion/algorithm/transformation/detail/replace_if.hpp | 24 +++++++++++++++++++-----
   sandbox/SOC/2009/fusion/boost/fusion/algorithm/transformation/replace.hpp | 33 +++++++++++++++++++++++++++++++++
   sandbox/SOC/2009/fusion/boost/fusion/support/category_of.hpp | 1 -
   sandbox/SOC/2009/fusion/build.bat | 2 +-
   sandbox/SOC/2009/fusion/libs/fusion/example/test/main.cpp | 3 ---
   sandbox/SOC/2009/fusion/project-root.jam | 2 +-
   7 files changed, 55 insertions(+), 11 deletions(-)

Modified: sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/find_key.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/find_key.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/algorithm/query/find_key.hpp 2009-09-05 07:08:33 EDT (Sat, 05 Sep 2009)
@@ -33,6 +33,7 @@
         {
             BOOST_FUSION_MPL_ASSERT((traits::is_sequence<Seq>));
             BOOST_FUSION_MPL_ASSERT((traits::is_forward<Seq>));
+ BOOST_FUSION_MPL_ASSERT((traits::is_associative<Seq>));
         };
     }
 

Modified: sandbox/SOC/2009/fusion/boost/fusion/algorithm/transformation/detail/replace_if.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/algorithm/transformation/detail/replace_if.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/algorithm/transformation/detail/replace_if.hpp 2009-09-05 07:08:33 EDT (Sat, 05 Sep 2009)
@@ -9,8 +9,9 @@
 #ifndef BOOST_FUSION_ALGORITHM_TRANSFORMATION_DETAIL_REPLACE_IF_HPP
 #define BOOST_FUSION_ALGORITHM_TRANSFORMATION_DETAIL_REPLACE_IF_HPP
 
-#include <boost/fusion/support/internal/result_of.hpp>
-
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/and.hpp>
 #include <boost/type_traits/is_convertible.hpp>
 #include <boost/type_traits/remove_const.hpp>
 
@@ -24,9 +25,22 @@
 
         template<typename Self, typename U>
         struct result<Self(U)>
- {
- typedef U type;
- };
+ : mpl::eval_if<
+ is_convertible<
+ typename remove_reference<NewValue>::type*
+ , typename remove_reference<U>::type*
+ >
+ , mpl::if_<
+ mpl::and_<
+ is_rref<NewValue>
+ , is_lrref<U>
+ >
+ , U
+ , typename remove_reference<U>::type&
+ >
+ , mpl::identity<U>
+ >
+ {};
 
         template<typename OtherF, typename OtherNewValue>
         replace_if_helper(

Modified: sandbox/SOC/2009/fusion/boost/fusion/algorithm/transformation/replace.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/algorithm/transformation/replace.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/algorithm/transformation/replace.hpp 2009-09-05 07:08:33 EDT (Sat, 05 Sep 2009)
@@ -14,6 +14,10 @@
 #include <boost/fusion/support/internal/ref.hpp>
 #include <boost/fusion/support/internal/assert.hpp>
 
+#ifdef BOOST_FUSION_ENABLE_STATIC_ASSERTS
+# include <boost/type_traits/is_convertible.hpp>
+#endif
+
 namespace boost { namespace fusion
 {
     namespace detail
@@ -80,6 +84,16 @@
             BOOST_FUSION_R_ELSE_CLREF(OldValue) old_value,
             BOOST_FUSION_R_ELSE_CLREF(NewValue) new_value)
     {
+ BOOST_FUSION_MPL_ASSERT((
+ is_convertible<
+ typename traits::deduce<
+ BOOST_FUSION_R_ELSE_CLREF(NewValue)
+ >::type*
+ , typename traits::deduce<
+ BOOST_FUSION_R_ELSE_CLREF(OldValue)
+ >::type*
+ >));
+
         typedef typename
             result_of::replace<
                 BOOST_FUSION_R_ELSE_CLREF(Seq)
@@ -92,6 +106,25 @@
                   , replacer(BOOST_FUSION_FORWARD(OldValue,old_value),0)
                   , BOOST_FUSION_FORWARD(NewValue,new_value));
     }
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
+ template <typename Seq, typename OldValue, typename NewValue>
+ inline typename result_of::replace<Seq&, OldValue const&>::type
+ replace(Seq& seq, OldValue const& old_value, NewValue const& new_value)
+ {
+ BOOST_FUSION_MPL_ASSERT((
+ is_convertible<
+ typename traits::deduce<NewValue const&>::type*
+ , typename traits::deduce<OldValue const&>::type*
+ >));
+
+ typedef typename
+ result_of::replace<Seq&, OldValue const&>::replacer
+ replacer;
+
+ return replace_if(seq,replacer(old_value,0), new_value);
+ }
+#endif
 }}
 
 #endif

Modified: sandbox/SOC/2009/fusion/boost/fusion/support/category_of.hpp
==============================================================================
--- sandbox/SOC/2009/fusion/boost/fusion/support/category_of.hpp (original)
+++ sandbox/SOC/2009/fusion/boost/fusion/support/category_of.hpp 2009-09-05 07:08:33 EDT (Sat, 05 Sep 2009)
@@ -22,7 +22,6 @@
 
 namespace boost { namespace fusion
 {
- //TODO necessary?
     struct incrementable_traversal_tag
     {};
 

Modified: sandbox/SOC/2009/fusion/build.bat
==============================================================================
--- sandbox/SOC/2009/fusion/build.bat (original)
+++ sandbox/SOC/2009/fusion/build.bat 2009-09-05 07:08:33 EDT (Sat, 05 Sep 2009)
@@ -22,7 +22,7 @@
             call :gcc3
         ) else (
             if "%1" == "" (
- call :vc9
+ call :gcc4
             ) else (
                 echo Unknown toolset '%1'
                 goto :eof

Modified: sandbox/SOC/2009/fusion/libs/fusion/example/test/main.cpp
==============================================================================
--- sandbox/SOC/2009/fusion/libs/fusion/example/test/main.cpp (original)
+++ sandbox/SOC/2009/fusion/libs/fusion/example/test/main.cpp 2009-09-05 07:08:33 EDT (Sat, 05 Sep 2009)
@@ -125,9 +125,6 @@
     }
 };
 
-struct C
-{};
-
 int main()
 {
     {

Modified: sandbox/SOC/2009/fusion/project-root.jam
==============================================================================
--- sandbox/SOC/2009/fusion/project-root.jam (original)
+++ sandbox/SOC/2009/fusion/project-root.jam 2009-09-05 07:08:33 EDT (Sat, 05 Sep 2009)
@@ -14,7 +14,7 @@
                    <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
     ;


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