|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60695 - in sandbox/SOC/2009/unicode/boost: iterator unicode
From: loufoque_at_[hidden]
Date: 2010-03-18 13:34:30
Author: mgaunard
Date: 2010-03-18 13:34:30 EDT (Thu, 18 Mar 2010)
New Revision: 60695
URL: http://svn.boost.org/trac/boost/changeset/60695
Log:
more ADL fixes + comments for join_iterator
Text files modified:
sandbox/SOC/2009/unicode/boost/iterator/join_iterator.hpp | 32 +++++++++++++++++++++++++-------
sandbox/SOC/2009/unicode/boost/unicode/cat.hpp | 16 ++++++++--------
sandbox/SOC/2009/unicode/boost/unicode/compose_fwd.hpp | 2 +-
3 files changed, 34 insertions(+), 16 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 13:34:30 EDT (Thu, 18 Mar 2010)
@@ -28,11 +28,16 @@
#include <boost/utility/enable_if.hpp>
#include <boost/utility/common_type.hpp>
+/* This file defines an iterator adapter to make a tuple of ranges appear
+ * as a single concatenated range */
+
namespace boost
{
namespace detail
{
+ /* Each iterator of the tuple must have a unique type to identify it
+ * in a variant, so it is wrapped */
template<typename T, int N>
struct wrapper : iterator_facade<
wrapper<T, N>,
@@ -94,6 +99,10 @@
return wrapper<T, N>(t);
}
+ /* We need to deduce what is the best type to hold any value out of
+ * the potentially slightly heterogeneous types in the tuple, and
+ * do that for value_type, reference and difference_type. */
+
template<typename RangeSequence>
struct deduce_value_type : common_type_seq<
mpl::transform_view<
@@ -170,9 +179,9 @@
Variant
>::type operator()(T& t) const
{
- if(++t == make_wrapper<T::index>(end(fusion::get<T::index>(tuple))))
+ if(++t == make_wrapper<T::index>(boost::end(fusion::get<T::index>(tuple))))
return make_wrapper<T::index+1>(
- begin(
+ boost::begin(
fusion::get<T::index+1>(tuple)
)
);
@@ -204,10 +213,10 @@
>::type
operator()(T& t) const
{
- if(t == make_wrapper<T::index>(begin(fusion::get<T::index>(tuple))))
+ if(t == make_wrapper<T::index>(boost::begin(fusion::get<T::index>(tuple))))
return make_wrapper<T::index-1>(
- prior(
- end(
+ boost::prior(
+ boost::end(
fusion::get<T::index-1>(tuple)
)
)
@@ -255,12 +264,12 @@
{
join_iterator() {} // singular
- join_iterator(const Tuple& t_) : t(t_), v(detail::make_wrapper<0>(begin(fusion::get<0>(t))))
+ join_iterator(const Tuple& t_) : t(t_), v(detail::make_wrapper<0>(boost::begin(fusion::get<0>(t))))
{
}
private:
- join_iterator(const Tuple& t_, bool) : t(t_), v(detail::make_wrapper<mpl::size<FusionTuple>::value-1>(end(fusion::get<mpl::size<FusionTuple>::value-1>(t))))
+ join_iterator(const Tuple& t_, bool) : t(t_), v(detail::make_wrapper<mpl::size<FusionTuple>::value-1>(boost::end(fusion::get<mpl::size<FusionTuple>::value-1>(t))))
{
}
@@ -332,6 +341,7 @@
);
}
+/* We convert ranges to iterator_range to avoid copying containers */
namespace detail
{
struct range_tuple_transformer
@@ -380,9 +390,17 @@
};
}
+/* Perfect forwarding with fusion::unfused + forward_adapter */
+#ifndef BOOST_UNICODE_DOXYGEN_INVOKED
forward_adapter<
fusion::unfused<detail::fused_make_range_tuple>
> joined_n;
+#else
+template<typename... T>
+join_iterator<
+ fusion::vector< sub_range<T>... >
+> joined_n(T&&... ranges);
+#endif
} // namespace boost
Modified: sandbox/SOC/2009/unicode/boost/unicode/cat.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/unicode/cat.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/unicode/cat.hpp 2010-03-18 13:34:30 EDT (Thu, 18 Mar 2010)
@@ -70,23 +70,23 @@
\
\
typename range_iterator<cv1 Range1>::type \
- new_end = combiner().rtl(begin(decoded1), end(decoded1)).base(); \
+ new_end = combiner().rtl(boost::begin(decoded1), boost::end(decoded1)).base(); \
\
typename range_iterator<cv2 Range2>::type \
- new_begin = combiner().ltr(begin(decoded2), end(decoded2)).base(); \
+ new_begin = combiner().ltr(boost::begin(decoded2), boost::end(decoded2)).base(); \
\
return make_tuple( \
- make_iterator_range(begin(range1), new_end), \
- make_iterator_range(new_end, end(range1)), \
- make_iterator_range(begin(range2), new_begin), \
- make_iterator_range(new_begin, end(range2)) \
+ make_iterator_range(boost::begin(range1), new_end), \
+ make_iterator_range(new_end, boost::end(range1)), \
+ make_iterator_range(boost::begin(range2), new_begin), \
+ make_iterator_range(new_begin, boost::end(range2)) \
); \
} \
\
return make_tuple( \
range1, \
- make_iterator_range(end(range1), end(range1)), \
- make_iterator_range(end(range2), end(range2)), \
+ make_iterator_range(boost::end(range1), boost::end(range1)), \
+ make_iterator_range(boost::end(range2), boost::end(range2)), \
range2 \
); \
}
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 13:34:30 EDT (Thu, 18 Mar 2010)
@@ -66,7 +66,7 @@
Out
> p = decompose_impl(
make_reversed_range(
- *prior(
+ *boost::prior(
make_consumer_iterator(begin, end, end, combiner())
)
),
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