Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60693 - in sandbox/SOC/2009/unicode/boost: iterator range unicode
From: loufoque_at_[hidden]
Date: 2010-03-18 11:56:18


Author: mgaunard
Date: 2010-03-18 11:56:17 EDT (Thu, 18 Mar 2010)
New Revision: 60693
URL: http://svn.boost.org/trac/boost/changeset/60693

Log:
moving to fusion-based perfect forwarding for joined_n and solving ADL issues with begin/end
Text files modified:
   sandbox/SOC/2009/unicode/boost/iterator/join_iterator.hpp | 162 ++++++++++++++++-----------------------
   sandbox/SOC/2009/unicode/boost/range/concepts.hpp | 13 +-
   sandbox/SOC/2009/unicode/boost/unicode/combining.hpp | 18 ++--
   sandbox/SOC/2009/unicode/boost/unicode/compose_fwd.hpp | 4
   4 files changed, 84 insertions(+), 113 deletions(-)

Modified: sandbox/SOC/2009/unicode/boost/iterator/join_iterator.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/iterator/join_iterator.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/iterator/join_iterator.hpp 2010-03-18 11:56:17 EDT (Thu, 18 Mar 2010)
@@ -28,12 +28,6 @@
 #include <boost/utility/enable_if.hpp>
 #include <boost/utility/common_type.hpp>
 
-#include <boost/preprocessor/repetition/enum_params.hpp>
-#include <boost/preprocessor/repetition/enum_binary_params.hpp>
-#include <boost/preprocessor/repetition/repeat.hpp>
-#include <boost/preprocessor/repetition/repeat_from_to.hpp>
-
-
 namespace boost
 {
     
@@ -251,13 +245,13 @@
  * a single concatenated range. */
 template<typename Tuple>
 struct join_iterator
- : iterator_facade<
- join_iterator<Tuple>,
+ : iterator_facade<
+ join_iterator<Tuple>,
         typename detail::deduce_value_type<typename fusion::result_of::as_vector<Tuple>::type>::type,
- std::bidirectional_iterator_tag,
+ std::bidirectional_iterator_tag,
         typename detail::deduce_reference<typename fusion::result_of::as_vector<Tuple>::type>::type,
         typename detail::deduce_difference_type<typename fusion::result_of::as_vector<Tuple>::type>::type
- >
+ >
 {
     join_iterator() {} // singular
     
@@ -271,32 +265,32 @@
     }
     
     friend join_iterator<Tuple> make_join_end_iterator<Tuple>(const Tuple& tuple);
- friend class boost::iterator_core_access;
+ friend class boost::iterator_core_access;
     typedef typename fusion::result_of::as_vector<Tuple>::type FusionTuple;
     typedef typename detail::deduce_reference<FusionTuple>::type Reference;
 
- Reference dereference() const
- {
- return apply_visitor(
+ Reference dereference() const
+ {
+ return apply_visitor(
             detail::dereference_visitor<Reference>(),
             v
         );
- }
-
- void increment()
- {
+ }
+
+ void increment()
+ {
         v = apply_visitor(detail::increment_visitor<FusionTuple, Variant>(t), v);
- }
-
- void decrement()
- {
+ }
+
+ void decrement()
+ {
         v = apply_visitor(detail::decrement_visitor<FusionTuple, Variant>(t), v);
- }
-
- bool equal(const join_iterator& other) const
- {
- return apply_visitor(detail::equal_visitor(), v, other.v);
- }
+ }
+
+ bool equal(const join_iterator& other) const
+ {
+ return apply_visitor(detail::equal_visitor(), v, other.v);
+ }
     
     FusionTuple t;
     typedef typename make_variant_over<
@@ -338,83 +332,57 @@
     );
 }
 
-struct range_transformer
+namespace detail
 {
- template<typename>
- struct result {};
-
- template<typename F, typename R>
- struct result<F(R&)>
+ struct range_tuple_transformer
     {
- typedef iterator_range<
- typename range_iterator<R>::type
- > type;
+ template<typename>
+ struct result {};
+
+ template<typename F, typename R>
+ struct result<F(R&)>
+ {
+ typedef iterator_range<
+ typename range_iterator<R>::type
+ > type;
+ };
+
+ template<typename Range>
+ typename result<range_tuple_transformer(Range&)>::type
+ operator()(Range& r) const
+ {
+ return make_iterator_range(r);
+ }
     };
     
- template<typename Range>
- typename result<range_transformer(Range&)>::type
- operator()(Range& r) const
+ struct fused_make_range_tuple
     {
- return make_iterator_range(r);
- }
-};
-
-struct fused_make_range_tuple
-{
- template<typename>
- struct result
- {
- };
+ template<typename>
+ struct result
+ {
+ };
+
+ template<typename F, typename Seq>
+ struct result<F(Seq&)>
+ {
+ typedef iterator_range< join_iterator<
+ typename fusion::result_of::transform<
+ Seq const,
+ range_tuple_transformer
+ >::type > > type;
+ };
     
- template<typename F, typename Seq>
- struct result<F(Seq&)>
- {
- typedef iterator_range< join_iterator< typename fusion::result_of::as_vector<
- typename fusion::result_of::transform<
- Seq const,
- range_transformer
- >::type
- >::type > > type;
+ template<class Seq>
+ typename result<fused_make_range_tuple(Seq&)>::type operator()(Seq const & s) const
+ {
+ return joined(fusion::transform(s, range_tuple_transformer()));
+ }
     };
+}
 
- template<class Seq>
- typename result<fused_make_range_tuple(Seq&)>::type operator()(Seq const & s) const
- {
- return joined(fusion::as_vector(fusion::transform(s, range_transformer())));
- }
-};
-
-/*forward_adapter<
- fusion::unfused<fused_make_range_tuple>
-> joined_n;*/
-
-#if 1
-#ifdef BOOST_UNICODE_DOXYGEN_INVOKED
-template<typename... T>
-iterator_range<
- join_iterator< tuple<T...> >
-> joined_n(const T&... n);
-#else
-#define BOOST_ITERATOR_JOIN_DEF(z, n, data) \
-template<BOOST_PP_ENUM_PARAMS(n, typename T)> \
-iterator_range< \
- join_iterator< tuple<BOOST_PP_REPEAT(n, BOOST_ITERATOR_JOIN_DEF_A, ~)> > \
-> joined_n(BOOST_PP_ENUM_BINARY_PARAMS(n, const T, & t)) \
-{ \
- return joined(make_tuple( \
- BOOST_PP_REPEAT(n, BOOST_ITERATOR_JOIN_DEF_B, ~) \
- )); \
-} \
- /**/
-#define BOOST_ITERATOR_JOIN_DEF_A(z, n, data) \
- BOOST_PP_COMMA_IF(n) iterator_range<typename range_iterator<const BOOST_PP_CAT(T, n)>::type> \
- /**/
-#define BOOST_ITERATOR_JOIN_DEF_B(z, n, data) \
- BOOST_PP_COMMA_IF(n) make_iterator_range(BOOST_PP_CAT(t, n)) \
- /**/
-BOOST_PP_REPEAT_FROM_TO(1, 5, BOOST_ITERATOR_JOIN_DEF, ~)
-#endif
-#endif
+forward_adapter<
+ fusion::unfused<detail::fused_make_range_tuple>
+> joined_n;
 
 } // namespace boost
 

Modified: sandbox/SOC/2009/unicode/boost/range/concepts.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/range/concepts.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/range/concepts.hpp 2010-03-18 11:56:17 EDT (Thu, 18 Mar 2010)
@@ -202,11 +202,14 @@
             ignore_unused_variable_warning(ci1);
             ignore_unused_variable_warning(ci2);
         }
-
- // Rationale:
- // The type of m_range is T& rather than T because it allows
- // T to be an abstract class.
- T& m_range;
+
+
+ SinglePassRangeConcept();
+
+ // Rationale:
+ // The type of m_range is T& rather than T because it allows
+ // T to be an abstract class.
+ T& m_range;
     };
 
     //! Check if a type T models the ForwardRange range concept.

Modified: sandbox/SOC/2009/unicode/boost/unicode/combining.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/unicode/combining.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/unicode/combining.hpp 2010-03-18 11:56:17 EDT (Thu, 18 Mar 2010)
@@ -49,16 +49,16 @@
     void not_stream_safe(Iterator begin, Iterator end)
     {
 #ifndef BOOST_NO_STD_LOCALE
- std::stringstream ss;
- ss << "Invalid Unicode stream-safe combining character sequence " << std::showbase << std::hex;
- for(Iterator it = begin; it != end; ++it)
- ss << *it << " ";
- ss << "encountered while trying to decompose UTF-32 sequence";
- std::out_of_range e(ss.str());
+ std::stringstream ss;
+ ss << "Invalid Unicode stream-safe combining character sequence " << std::showbase << std::hex;
+ for(Iterator it = begin; it != end; ++it)
+ ss << *it << " ";
+ ss << "encountered while trying to decompose UTF-32 sequence";
+ std::out_of_range e(ss.str());
 #else
- std::out_of_range e("Invalid Unicode stream-safe combining character sequence encountered while trying to decompose UTF-32 sequence");
+ std::out_of_range e("Invalid Unicode stream-safe combining character sequence encountered while trying to decompose UTF-32 sequence");
 #endif
- boost::throw_exception(e);
+ boost::throw_exception(e);
     }
     
     template<typename Iterator, typename OutputIterator>
@@ -139,7 +139,7 @@
     template<typename Range, typename Out>
     std::pair<typename range_iterator<const Range>::type, Out> combine_sort_impl(const Range& range, Out out)
     {
- return std::make_pair(end(range), combine_sort_impl(begin(range), end(range), out));
+ return std::make_pair(boost::end(range), combine_sort_impl(boost::begin(range), boost::end(range), out));
     }
 
     template<typename In, typename Out>

Modified: sandbox/SOC/2009/unicode/boost/unicode/compose_fwd.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/unicode/compose_fwd.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/unicode/compose_fwd.hpp 2010-03-18 11:56:17 EDT (Thu, 18 Mar 2010)
@@ -80,7 +80,7 @@
     template<typename Range, typename Out>
     std::pair<typename range_iterator<const Range>::type, Out> decompose_impl(const Range& range, Out out)
     {
- return std::make_pair(end(range), decompose_impl(begin(range), end(range), out));
+ return std::make_pair(boost::end(range), decompose_impl(boost::begin(range), boost::end(range), out));
     }
     
     template<typename In, typename Out>
@@ -191,7 +191,7 @@
         iterator_range<const char32*> dec = ucd::get_decomposition(ch);
         if(!empty(dec) && ((1 << ucd::get_decomposition_type(ch)) & mask))
         {
- for(const char32* p = begin(dec); p != end(dec); ++p)
+ for(const char32* p = boost::begin(dec); p != boost::end(dec); ++p)
                 out = decompose_rec(*p, out);
             return out;
         }


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