Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56383 - trunk/boost/fusion/view/nview
From: hartmut.kaiser_at_[hidden]
Date: 2009-09-25 13:24:56


Author: hkaiser
Date: 2009-09-25 13:24:55 EDT (Fri, 25 Sep 2009)
New Revision: 56383
URL: http://svn.boost.org/trac/boost/changeset/56383

Log:
Fusion: fixed another const correctness problem
Text files modified:
   trunk/boost/fusion/view/nview/nview.hpp | 27 ++++++++++++++++++++++++---
   1 files changed, 24 insertions(+), 3 deletions(-)

Modified: trunk/boost/fusion/view/nview/nview.hpp
==============================================================================
--- trunk/boost/fusion/view/nview/nview.hpp (original)
+++ trunk/boost/fusion/view/nview/nview.hpp 2009-09-25 13:24:55 EDT (Fri, 25 Sep 2009)
@@ -31,7 +31,7 @@
             struct result;
 
             template<typename U>
- struct result<addref(U)> : boost::add_reference<U> {};
+ struct result<addref(U)> : add_reference<U> {};
 
             template <typename T>
             typename boost::result_of<addref(T)>::type
@@ -40,6 +40,24 @@
                 return x;
             }
         };
+
+ struct addconstref
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename U>
+ struct result<addconstref(U)>
+ : add_reference<typename add_const<U>::type>
+ {};
+
+ template <typename T>
+ typename boost::result_of<addconstref(T)>::type
+ operator()(T& x) const
+ {
+ return x;
+ }
+ };
     }
 
     struct nview_tag;
@@ -58,12 +76,15 @@
         typedef Indicies index_type;
         typedef typename mpl::size<Indicies>::type size;
 
- typedef transform_view<Sequence, detail::addref> transform_view_type;
+ typedef typename mpl::if_<
+ is_const<Sequence>, detail::addconstref, detail::addref
+ >::type transform_type;
+ typedef transform_view<Sequence, transform_type> transform_view_type;
         typedef typename result_of::as_vector<transform_view_type>::type
             sequence_type;
 
         explicit nview(Sequence& val)
- : seq(as_vector(transform_view_type(val, detail::addref())))
+ : seq(sequence_type(transform_view_type(val, transform_type())))
         {}
 
         sequence_type seq;


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