$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r56812 - sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/functor
From: erwann.rogard_at_[hidden]
Date: 2009-10-13 22:03:20
Author: e_r
Date: 2009-10-13 22:03:19 EDT (Tue, 13 Oct 2009)
New Revision: 56812
URL: http://svn.boost.org/trac/boost/changeset/56812
Log:
a
Added:
   sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/functor/map_identity_f.hpp   (contents, props changed)
Added: sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/functor/map_identity_f.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/fusion/boost/statistics/detail/fusion/functor/map_identity_f.hpp	2009-10-13 22:03:19 EDT (Tue, 13 Oct 2009)
@@ -0,0 +1,114 @@
+//////////////////////////////////////////////////////////////////////////////
+// detail::fusion::functor::map_identity_f.hpp                              //
+//                                                                          //
+//  (C) Copyright 2009 Erwann Rogard                                        //
+//  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)        //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_STATISTICS_DETAIL_FUSION_MAP_IDENTITY_F_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_FUSION_MAP_IDENTITY_F_HPP_ER_2009
+#include <boost/utility/result_of.hpp>
+
+#include <boost/fusion/include/pair.hpp>
+
+
+#include <boost/fusion/container/map.hpp>
+#include <boost/fusion/include/map.hpp>
+#include <boost/fusion/include/map_fwd.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/include/at_key.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace fusion{
+namespace functor{
+
+    template<typename K1,typename K2,typename F>
+    class map_identity_f{
+    
+        public:
+
+        struct identity
+        {
+            typedef K1 key_;
+            template<typename X>
+            struct apply{
+                typedef boost::fusion::pair<K1,X> pair_;
+            };
+        };
+        
+        struct function
+        {
+            typedef K2 key_;
+
+            template<typename X>
+            struct apply{
+                typedef typename boost::result_of<F(const X&)>::type cr_data2_;
+                typedef typename remove_cv<
+                    typename remove_reference<
+                        cr_data2_
+                    >::type
+                >::type data2_;
+                typedef boost::fusion::pair<K2,data2_> pair_;
+            };
+        };
+
+        map_identity_f()
+            {}
+        map_identity_f(const F& f)
+            :f_(f){}
+        map_identity_f(const map_identity_f& that)
+            :f_(that.f_){}
+
+        map_identity_f& operator=(const map_identity_f& that)
+        {
+            if(&that!=this)
+            {
+                //static_cast<F&>(*this) = static_cast<const F&>(that);
+                this->f_ = that.f_;
+            }
+            return *this;
+        }
+
+        template<typename S>    
+        struct result{};
+
+        template<typename F1,typename X>
+        struct result<F1(const X&)>
+        {
+            typedef typename identity::template apply<X> app1_;
+            typedef typename function::template apply<X> app2_;
+            typedef typename app1_::pair_ p1_;
+            typedef typename app2_::pair_ p2_;
+            typedef boost::fusion::map<p1_,p2_> type;
+        };
+
+        template<typename S>
+        struct sig : result<S>{};
+
+        template<typename X>
+        typename result<map_identity_f(const X&)>::type
+        operator()(const X& x)const
+        {
+            typedef typename result<map_identity_f(const X&)>::type type;
+            return type(
+                boost::fusion::make_pair<K1>(x),
+                boost::fusion::make_pair<K2>(
+                    this->f_(x)
+                )
+            );
+        }
+    
+        private:
+        F f_;
+    };
+
+}// functor
+}// fusion
+}// detail
+}// statistics
+}// boost
+
+#endif