Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55289 - in sandbox/SOC/2009/unicode: boost boost/iterator boost/unicode libs/unicode/doc libs/unicode/doc/concepts
From: loufoque_at_[hidden]
Date: 2009-07-30 14:45:32


Author: mgaunard
Date: 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
New Revision: 55289
URL: http://svn.boost.org/trac/boost/changeset/55289

Log:
More concept checking and updated concepts
Added:
   sandbox/SOC/2009/unicode/boost/iterator/consumer_concept.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/iterator/consumer_iterator_fwd.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/iterator/pipe_concept.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator_fwd.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2009/unicode/boost/cuchar.hpp | 15 -
   sandbox/SOC/2009/unicode/boost/iterator/consumer_iterator.hpp | 148 +++++++++--------
   sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp | 326 ++-------------------------------------
   sandbox/SOC/2009/unicode/boost/unicode/graphemes.hpp | 2
   sandbox/SOC/2009/unicode/boost/unicode/utf_codecs.hpp | 33 +++
   sandbox/SOC/2009/unicode/libs/unicode/doc/Jamfile.v2 | 3
   sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/BoundaryChecker.xml | 11 +
   sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/Consumer.xml | 11 +
   sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/OneManyPipe.xml | 13 +
   sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/Pipe.xml | 13 +
   10 files changed, 177 insertions(+), 398 deletions(-)

Modified: sandbox/SOC/2009/unicode/boost/cuchar.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/cuchar.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/cuchar.hpp 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -2,25 +2,22 @@
 #define BOOST_CUCHAR_HPP
 
 #include <boost/cstdint.hpp>
+#include <boost/detail/unspecified.hpp>
 
 namespace boost
 {
 #if defined(BOOST_NO_CHAR16_T)
- typedef boost::uint_least16_t char16;
-#elif defined(BOOST_UNICODE_DOXYGEN_INVOKED)
- /** Typedef to C++0x char16_t, or uint_least16_t from cstdint if not available. **/
- typedef detail::char16 char16;
+ typedef uint_least16_t char16;
 #else
- typedef char16_t char16;
+ /** Typedef to C++0x char16_t, or uint_least16_t from cstdint if not available. **/
+ typedef detail::unspecified<char16_t>::type char16;
 #endif
         
 #if defined(BOOST_NO_CHAR32_T)
         typedef boost::uint_least32_t char32;
-#elif defined(BOOST_UNICODE_DOXYGEN_INVOKED)
- /** Typedef to C++0x char32_t, or uint_least32_t from cstdint if not available. **/
- typedef detail::char32 char32;
 #else
- typedef char32_t char32;
+ /** Typedef to C++0x char32_t, or uint_least32_t from cstdint if not available. **/
+ typedef detail::unspecified<char32_t>::type char32;
 #endif
     
 } // namespace boost

Added: sandbox/SOC/2009/unicode/boost/iterator/consumer_concept.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/iterator/consumer_concept.hpp 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -0,0 +1,53 @@
+#ifndef BOOST_ITERATOR_CONSUMER_CONCEPT_HPP
+#define BOOST_ITERATOR_CONSUMER_CONCEPT_HPP
+
+#include <boost/concept_archetype.hpp>
+#include <boost/concept_check.hpp>
+
+namespace boost
+{
+
+/** Concept checking class for the \c Consumer concept */
+template<typename X>
+struct ConsumerConcept : DefaultConstructible<X>, CopyConstructible<X>
+{
+ typedef typename X::input_type input_type;
+
+ BOOST_CONCEPT_USAGE(ConsumerConcept)
+ {
+ X c;
+ begin = c.ltr(begin, end);
+ end = c.rtl(begin, end);
+ }
+
+private:
+ typedef bidirectional_iterator_archetype<input_type> in_type;
+
+ in_type begin;
+ in_type end;
+};
+
+/** Concept checking class for the \c BoundaryChecker concept */
+template<typename X>
+struct BoundaryCheckerConcept : DefaultConstructible<X>, CopyConstructible<X>
+{
+ typedef typename X::input_type input_type;
+
+ BOOST_CONCEPT_USAGE(BoundaryCheckerConcept)
+ {
+ X b;
+ result = b(begin, end, pos);
+ }
+
+private:
+ typedef bidirectional_iterator_archetype<input_type> in_type;
+ in_type begin;
+ in_type end;
+ in_type pos;
+
+ bool result;
+};
+
+} // namespace boost
+
+#endif

Modified: sandbox/SOC/2009/unicode/boost/iterator/consumer_iterator.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/iterator/consumer_iterator.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/iterator/consumer_iterator.hpp 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -1,10 +1,13 @@
-#ifndef BOOST_CONSUMER_ITERATOR_HPP
-#define BOOST_CONSUMER_ITERATOR_HPP
+#ifndef BOOST_ITERATOR_CONSUMER_ITERATOR_HPP
+#define BOOST_ITERATOR_CONSUMER_ITERATOR_HPP
 
-#include <boost/iterator/iterator_facade.hpp>
 #include <boost/iterator/dummy_output_iterator.hpp>
 
-#include <boost/range.hpp>
+#include <boost/concept/requires.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/iterator/pipe_concept.hpp>
+
+#include <boost/iterator/consumer_iterator_fwd.hpp>
 
 namespace boost
 {
@@ -13,6 +16,10 @@
 template<typename Pipe>
 struct pipe_consumer : private Pipe
 {
+ BOOST_CONCEPT_ASSERT((PipeConcept<Pipe>));
+
+ typedef typename Pipe::input_type input_type;
+
     pipe_consumer() {} // singular
     
     pipe_consumer(Pipe p_) : Pipe(p_)
@@ -33,7 +40,10 @@
 };
 
 template<typename Pipe>
-pipe_consumer<Pipe> make_pipe_consumer(Pipe p)
+BOOST_CONCEPT_REQUIRES(
+ ((PipeConcept<Pipe>)),
+ (pipe_consumer<Pipe>)
+) make_pipe_consumer(Pipe p)
 {
     return pipe_consumer<Pipe>(p);
 }
@@ -42,6 +52,10 @@
 template<typename BoundaryChecker>
 struct boundary_consumer : private BoundaryChecker
 {
+ BOOST_CONCEPT_ASSERT((BoundaryCheckerConcept<BoundaryChecker>));
+
+ typedef typename BoundaryChecker::input_type input_type;
+
     boundary_consumer() {} // singular
     
     boundary_consumer(BoundaryChecker b_) : BoundaryChecker(b_)
@@ -72,7 +86,10 @@
 };
 
 template<typename BoundaryChecker>
-boundary_consumer<BoundaryChecker> make_boundary_consumer(BoundaryChecker b)
+BOOST_CONCEPT_REQUIRES(
+ ((BoundaryCheckerConcept<BoundaryChecker>)),
+ (boundary_consumer<BoundaryChecker>)
+) make_boundary_consumer(BoundaryChecker b)
 {
     return boundary_consumer<BoundaryChecker>(b);
 }
@@ -82,6 +99,15 @@
 template<typename B1, typename Pipe, typename B2>
 struct multi_boundary
 {
+ BOOST_CONCEPT_ASSERT((BoundaryCheckerConcept<B1>));
+ BOOST_CONCEPT_ASSERT((PipeConcept<Pipe>));
+ BOOST_CONCEPT_ASSERT((BoundaryCheckerConcept<B2>));
+
+ BOOST_CONCEPT_ASSERT((Convertible<typename B1::input_type, typename Pipe::input_type>));
+ BOOST_CONCEPT_ASSERT((Convertible<typename Pipe::output_type, typename B2::input_type>));
+
+ typedef typename B1::input_type input_type;
+
     multi_boundary() // singular
     {
     }
@@ -108,7 +134,14 @@
 };
 
 template<typename B1, typename Pipe, typename B2>
-multi_boundary<B1, Pipe, B2> make_multi_boundary(B1 b1, Pipe p, B2 b2)
+BOOST_CONCEPT_REQUIRES(
+ ((BoundaryCheckerConcept<B1>))
+ ((PipeConcept<Pipe>))
+ ((BoundaryCheckerConcept<B2>))
+ ((Convertible<typename B1::input_type, typename Pipe::input_type>))
+ ((Convertible<typename Pipe::output_type, typename B2::input_type>)),
+ (multi_boundary<B1, Pipe, B2>)
+) make_multi_boundary(B1 b1, Pipe p, B2 b2)
 {
     return multi_boundary<B1, Pipe, B2>(b1, p, b2);
 }
@@ -118,6 +151,13 @@
 template<typename Pipe, typename Consumer>
 struct piped_consumer
 {
+ BOOST_CONCEPT_ASSERT((PipeConcept<Pipe>));
+ BOOST_CONCEPT_ASSERT((ConsumerConcept<Consumer>));
+
+ BOOST_CONCEPT_ASSERT((Convertible<typename Pipe::output_type, typename Consumer::input_type>));
+
+ typedef typename Pipe::input_type input_type;
+
     piped_consumer() // singular
     {
     }
@@ -150,81 +190,38 @@
 };
 
 template<typename Pipe, typename Consumer>
-piped_consumer<Pipe, Consumer> make_piped_consumer(Pipe p, Consumer c)
+BOOST_CONCEPT_REQUIRES(
+ ((PipeConcept<Pipe>))
+ ((ConsumerConcept<Consumer>))
+ ((Convertible<typename Pipe::output_type, typename Consumer::input_type>)),
+ (piped_consumer<Pipe, Consumer>)
+) make_piped_consumer(Pipe p, Consumer c)
 {
     return piped_consumer<Pipe, Consumer>(p, c);
 }
 
-/** Iterator adapter that wraps a range to make it appear like a range
- * of subranges, each subrange being a step of a \c Consumer invocation. */
-template<typename It, typename Consumer>
-struct consumer_iterator
- : boost::iterator_facade<
- consumer_iterator<It, Consumer>,
- boost::iterator_range<It>,
- std::bidirectional_iterator_tag,
- const boost::iterator_range<It>
- >
-{
- consumer_iterator() {} // singular
-
- consumer_iterator(It begin_, It end_, It pos_, Consumer c_) : pos(pos_), begin(begin_), end(end_), p(c_)
- {
- if(pos != end)
- next_pos = p.ltr(pos, end);
- }
-
- It base() const
- {
- return pos;
- }
 
-private:
- friend class boost::iterator_core_access;
-
- boost::iterator_range<It> dereference() const
- {
- return boost::make_iterator_range(pos, next_pos);
- }
-
- void increment()
- {
- pos = next_pos;
- if(pos != end)
- next_pos = p.ltr(pos, end);
- }
-
- void decrement()
- {
- next_pos = pos;
-
- pos = p.rtl(begin, pos);
- }
-
- bool equal(const consumer_iterator& other) const
- {
- return pos == other.pos;
- }
-
- It pos;
- It next_pos;
-
- It begin;
- It end;
-
- Consumer p;
-};
 
 template<typename It, typename Consumer>
-consumer_iterator<It, Consumer> make_consumer_iterator(It begin, It end, It pos, Consumer c)
+BOOST_CONCEPT_REQUIRES(
+ ((InputIterator<It>))
+ ((ConsumerConcept<Consumer>))
+ ((Convertible<typename InputIterator<It>::value_type, typename Consumer::input_type>)),
+ (consumer_iterator<It, Consumer>)
+) make_consumer_iterator(It begin, It end, It pos, Consumer c)
 {
         return consumer_iterator<It, Consumer>(begin, end, pos, c);
 }
 
 template<typename Range, typename Consumer>
-boost::iterator_range<
- consumer_iterator<typename boost::range_iterator<const Range>::type, Consumer>
-> consumed(const Range& range, Consumer c)
+BOOST_CONCEPT_REQUIRES(
+ ((SinglePassRangeConcept<Range>))
+ ((ConsumerConcept<Consumer>))
+ ((Convertible<typename range_value<const Range>::type, typename Consumer::input_type>)),
+ (iterator_range<
+ consumer_iterator<typename range_iterator<const Range>::type, Consumer>
+ >)
+) consumed(const Range& range, Consumer c)
 {
         return boost::make_iterator_range(
                 make_consumer_iterator(boost::begin(range), boost::end(range), boost::begin(range), c),
@@ -233,9 +230,14 @@
 }
 
 template<typename Range, typename Consumer>
-boost::iterator_range<
- consumer_iterator<typename boost::range_iterator<Range>::type, Consumer>
-> consumed(Range& range, Consumer c)
+BOOST_CONCEPT_REQUIRES(
+ ((SinglePassRangeConcept<Range>))
+ ((ConsumerConcept<Consumer>))
+ ((Convertible<typename range_value<Range>::type, typename Consumer::input_type>)),
+ (iterator_range<
+ consumer_iterator<typename range_iterator<Range>::type, Consumer>
+ >)
+) consumed(Range& range, Consumer c)
 {
         return boost::make_iterator_range(
                 make_consumer_iterator(boost::begin(range), boost::end(range), boost::begin(range), c),

Added: sandbox/SOC/2009/unicode/boost/iterator/consumer_iterator_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/iterator/consumer_iterator_fwd.hpp 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -0,0 +1,82 @@
+#ifndef BOOST_ITERATOR_CONSUMER_ITERATOR_FWD_HPP
+#define BOOST_ITERATOR_CONSUMER_ITERATOR_FWD_HPP
+
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/range.hpp>
+
+#include <boost/iterator/consumer_concept.hpp>
+
+namespace boost
+{
+
+/** Iterator adapter that wraps a range to make it appear like a range
+ * of subranges, each subrange being a step of a \c Consumer invocation. */
+template<typename It, typename Consumer>
+struct consumer_iterator
+ : iterator_facade<
+ consumer_iterator<It, Consumer>,
+ iterator_range<It>,
+ std::bidirectional_iterator_tag,
+ const iterator_range<It>
+ >
+{
+ BOOST_CONCEPT_ASSERT((InputIterator<It>));
+ BOOST_CONCEPT_ASSERT((ConsumerConcept<Consumer>));
+ BOOST_CONCEPT_ASSERT((Convertible<typename InputIterator<It>::value_type, typename Consumer::input_type>));
+
+ consumer_iterator() {} // singular
+
+ consumer_iterator(It begin_, It end_, It pos_, Consumer c_) : pos(pos_), begin(begin_), end(end_), p(c_)
+ {
+ if(pos != end)
+ next_pos = p.ltr(pos, end);
+ }
+
+ It base() const
+ {
+ BOOST_CONCEPT_ASSERT((ForwardIterator<It>));
+
+ return pos;
+ }
+
+private:
+ friend class boost::iterator_core_access;
+
+ iterator_range<It> dereference() const
+ {
+ return make_iterator_range(pos, next_pos);
+ }
+
+ void increment()
+ {
+ pos = next_pos;
+ if(pos != end)
+ next_pos = p.ltr(pos, end);
+ }
+
+ void decrement()
+ {
+ BOOST_CONCEPT_ASSERT((BidirectionalIterator<It>));
+
+ next_pos = pos;
+
+ pos = p.rtl(begin, pos);
+ }
+
+ bool equal(const consumer_iterator& other) const
+ {
+ return pos == other.pos;
+ }
+
+ It pos;
+ It next_pos;
+
+ It begin;
+ It end;
+
+ Consumer p;
+};
+
+} // namespace boost
+
+#endif

Added: sandbox/SOC/2009/unicode/boost/iterator/pipe_concept.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/iterator/pipe_concept.hpp 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -0,0 +1,58 @@
+#ifndef BOOST_ITERATOR_PIPE_CONCEPT_HPP
+#define BOOST_ITERATOR_PIPE_CONCEPT_HPP
+
+#include <boost/concept_archetype.hpp>
+#include <boost/concept_check.hpp>
+
+#include <utility>
+
+namespace boost
+{
+
+/** Concept checking class for the \c Pipe concept */
+template<typename X>
+struct PipeConcept : DefaultConstructible<X>, CopyConstructible<X>
+{
+ typedef typename X::input_type input_type;
+ typedef typename X::output_type output_type;
+
+ BOOST_CONCEPT_USAGE(PipeConcept)
+ {
+ X pipe;
+ p = pipe.ltr(begin, end, out);
+ p = pipe.rtl(begin, end, out);
+ }
+
+private:
+ typedef bidirectional_iterator_archetype<input_type> in_type;
+ typedef output_iterator_archetype<output_type> out_type;
+
+ in_type begin;
+ in_type end;
+ out_type out;
+ std::pair<in_type, out_type> p;
+};
+
+/** Concept checking class for the \c OneManyPipe concept */
+template<typename X>
+struct OneManyPipeConcept : DefaultConstructible<X>, CopyConstructible<X>
+{
+ typedef typename X::input_type input_type;
+ typedef typename X::output_type output_type;
+
+ BOOST_CONCEPT_USAGE(OneManyPipeConcept)
+ {
+ X pipe;
+ out = pipe(in, out);
+ }
+
+private:
+ typedef output_iterator_archetype<output_type> out_type;
+
+ input_type in;
+ out_type out;
+};
+
+} // namespace boost
+
+#endif

Modified: sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -1,149 +1,19 @@
-#ifndef BOOST_PIPE_ITERATOR_HPP
-#define BOOST_PIPE_ITERATOR_HPP
+#ifndef BOOST_ITERATOR_PIPE_ITERATOR_HPP
+#define BOOST_ITERATOR_PIPE_ITERATOR_HPP
 
-#include <boost/iterator/iterator_facade.hpp>
-#include <vector>
+#include <boost/assert.hpp>
 #include <utility>
 
 #include <boost/range.hpp>
-#include <boost/assert.hpp>
-
-#include <boost/utility/enable_if.hpp>
-#include <boost/mpl/has_xxx.hpp>
 #include <boost/mpl/int.hpp>
 
-#include <boost/concept_check.hpp>
 #include <boost/concept/requires.hpp>
-#include <boost/concept_archetype.hpp>
 #include <boost/range/concepts.hpp>
 
-namespace boost
-{
-
-struct any_type
-{
- operator bool() const
- {
- return false;
- }
-};
-
-template<typename X>
-struct PipeConcept : CopyConstructible<X>
-{
- typedef typename X::output_type output_type;
-
- BOOST_CONCEPT_USAGE(PipeConcept)
- {
- X pipe;
- std::pair<in1_type, out_type> p1 = pipe.ltr(begin1, end1, out);
- std::pair<in2_type, out_type> p2 = pipe.rtl(begin2, end2, out);
- (void)p1;
- (void)p2;
- }
-
-private:
- typedef input_iterator_archetype_no_proxy<any_type> in1_type;
- typedef bidirectional_iterator_archetype<any_type> in2_type;
- typedef output_iterator_archetype<output_type> out_type;
-
- in1_type begin1;
- in1_type end1;
- in2_type begin2;
- in2_type end2;
- out_type out;
-};
+#include <boost/iterator/pipe_iterator_fwd.hpp>
 
-template<typename X>
-struct OneManyPipeConcept : CopyConstructible<X>
-{
- typedef typename X::output_type output_type;
-
- BOOST_CONCEPT_USAGE(OneManyPipeConcept)
- {
- X pipe;
- out = pipe(any_type(), out);
- }
-
-private:
- typedef output_iterator_archetype<output_type> out_type;
- out_type out;
-};
-
-namespace detail
+namespace boost
 {
- BOOST_MPL_HAS_XXX_TRAIT_DEF(max_output)
-
- template<typename P, typename Enable = void>
- struct pipe_output_storage;
-
- template<typename P>
- struct pipe_output_storage<P, typename ::boost::disable_if< has_max_output<P> >::type>
- {
- BOOST_CONCEPT_ASSERT((PipeConcept<P>));
-private:
- typedef std::vector<typename P::output_type> Values;
-public:
- typedef std::back_insert_iterator<Values> output_iterator;
-
- const typename P::output_type& operator[](size_t i) const
- {
- return values[i];
- }
-
- size_t last_index() const
- {
- return values.size() - 1;
- }
-
- output_iterator out()
- {
- values.clear();
- return std::back_inserter(values);
- }
-
- void update(output_iterator)
- {
- }
-
- private:
- Values values;
- };
-
- template<typename P>
- struct pipe_output_storage<P, typename boost::enable_if< has_max_output<P> >::type>
- {
- BOOST_CONCEPT_ASSERT((PipeConcept<P>));
-private:
- typedef typename P::output_type Value;
-public:
- typedef Value* output_iterator;
-
- const Value& operator[](size_t i) const
- {
- return values[i];
- }
-
- size_t last_index() const
- {
- return last;
- }
-
- output_iterator out()
- {
- return values;
- }
-
- void update(output_iterator u)
- {
- last = u - values - 1;
- }
-
- private:
- Value values[P::max_output::value];
- size_t last;
- };
-}
 
 /** Model of \c Pipe constructed from a model of \c OneManyPipe */
 template<typename OneManyPipe>
@@ -163,7 +33,7 @@
         {
                 BOOST_ASSERT(begin != end);
                 
- out = ((OneManyPipe&)(*this))(*begin, out);
+ out = OneManyPipe::operator()(*begin, out);
                 return std::make_pair(++begin, out);
         }
         
@@ -173,7 +43,7 @@
         {
                 BOOST_ASSERT(begin != end);
                 
- out = ((OneManyPipe&)(*this))(*--end, out);
+ out = OneManyPipe::operator()(*--end, out);
                 return std::make_pair(end, out);
         }
 };
@@ -192,6 +62,7 @@
 template<typename T>
 struct cast_pipe
 {
+ typedef T input_type;
     typedef T output_type;
     typedef mpl::int_<1> max_output;
     
@@ -203,111 +74,11 @@
     }
 };
 
-/** Iterator adapter that wraps a range to make it appear like a converted
- * one, by converting it step-by-step as it is advanced. */
-template<typename It, typename Pipe>
-struct pipe_iterator
- : boost::iterator_facade<
- pipe_iterator<It, Pipe>,
- typename Pipe::output_type,
- std::bidirectional_iterator_tag,
- const typename Pipe::output_type
- >
-{
- BOOST_CONCEPT_ASSERT((InputIterator<It>));
- BOOST_CONCEPT_ASSERT((PipeConcept<Pipe>));
-
- pipe_iterator() {} // singular
-
- pipe_iterator(It begin_, It end_, It pos_, Pipe p_) : pos(pos_), begin(begin_), end(end_), index(0), p(p_)
- {
- if(pos != end)
- {
- std::pair<It, typename detail::pipe_output_storage<Pipe>::output_iterator> pair =
- p.ltr(pos, end, values.out());
- next_pos = pair.first;
- values.update(pair.second);
- }
- }
-
- It base() const
- {
- BOOST_CONCEPT_ASSERT((ForwardIterator<It>));
-
- return pos;
- }
-
-private:
- typedef typename Pipe::output_type T;
-
- friend class boost::iterator_core_access;
-
- T dereference() const
- {
- return values[index];
- }
-
- void increment()
- {
- if(index != values.last_index())
- {
- index++;
- }
- else
- {
- pos = next_pos;
- if(pos != end)
- {
- std::pair<It, typename detail::pipe_output_storage<Pipe>::output_iterator> pair =
- p.ltr(pos, end, values.out());
- next_pos = pair.first;
- values.update(pair.second);
- }
- index = 0;
- }
- }
-
- void decrement()
- {
- BOOST_CONCEPT_ASSERT((BidirectionalIterator<It>));
-
- if(index != 0)
- {
- index--;
- }
- else
- {
- next_pos = pos;
-
- std::pair<It, typename detail::pipe_output_storage<Pipe>::output_iterator> pair =
- p.rtl(begin, pos, values.out());
- pos = pair.first;
- values.update(pair.second);
-
- index = values.last_index();
- }
- }
-
- bool equal(const pipe_iterator& other) const
- {
- return pos == other.pos && index == other.index;
- }
-
- It pos;
- It next_pos;
-
- It begin;
- It end;
- size_t index;
-
- Pipe p;
-
- detail::pipe_output_storage<Pipe> values;
-};
-
 template<typename It, typename Pipe>
 BOOST_CONCEPT_REQUIRES(
- ((InputIterator<It>)),
+ ((InputIterator<It>))
+ ((PipeConcept<Pipe>))
+ ((Convertible<typename InputIterator<It>::value_type, typename Pipe::input_type>)),
     (pipe_iterator<It, Pipe>)
 ) make_pipe_iterator(It begin, It end, It pos, Pipe p)
 {
@@ -317,9 +88,10 @@
 template<typename Range, typename Pipe>
 BOOST_CONCEPT_REQUIRES(
     ((SinglePassRangeConcept<Range>))
- ((PipeConcept<Pipe>)),
- (boost::iterator_range<
- pipe_iterator<typename boost::range_iterator<const Range>::type, Pipe>
+ ((PipeConcept<Pipe>))
+ ((Convertible<typename range_value<Range>::type, typename Pipe::input_type>)),
+ (iterator_range<
+ pipe_iterator<typename range_iterator<const Range>::type, Pipe>
>)
 ) piped(const Range& range, Pipe p)
 {
@@ -332,9 +104,10 @@
 template<typename Range, typename Pipe>
 BOOST_CONCEPT_REQUIRES(
     ((SinglePassRangeConcept<Range>))
- ((PipeConcept<Pipe>)),
- (boost::iterator_range<
- pipe_iterator<typename boost::range_iterator<Range>::type, Pipe>
+ ((PipeConcept<Pipe>))
+ ((Convertible<typename range_value<Range>::type, typename Pipe::input_type>)),
+ (iterator_range<
+ pipe_iterator<typename range_iterator<Range>::type, Pipe>
>)
 ) piped(Range& range, Pipe p)
 {
@@ -348,6 +121,7 @@
 BOOST_CONCEPT_REQUIRES(
     ((SinglePassRangeConcept<Range>))
     ((PipeConcept<Pipe>))
+ ((Convertible<typename range_value<Range>::type, typename Pipe::input_type>))
     ((OutputIteratorConcept<OutputIterator, typename Pipe::output_type>)),
     (OutputIterator)
 ) pipe(const Range& range, Pipe pipe, OutputIterator out)
@@ -367,66 +141,6 @@
     return out;
 }
 
-/** Output Iterator adapter that wraps an output iterator to make one
- * that will convert its output before pushing it to the wrapped iterator. */
-template<typename It, typename OneManyPipe>
-struct pipe_output_iterator
-{
- BOOST_CONCEPT_ASSERT((OneManyPipeConcept<OneManyPipe>));
-
- typedef void difference_type;
- typedef void value_type;
- typedef pipe_output_iterator<It, OneManyPipe>* pointer;
- typedef pipe_output_iterator<It, OneManyPipe>& reference;
- typedef std::output_iterator_tag iterator_category;
-
- pipe_output_iterator() {} // singular
-
- pipe_output_iterator(It pos_, OneManyPipe p_) : pos(pos_), p(p_)
- {
- }
-
- It base() const
- {
- return pos;
- }
-
- const pipe_output_iterator& operator*() const
- {
- return *this;
- }
-
- pipe_output_iterator& operator++()
- {
- return *this;
- }
-
- pipe_output_iterator& operator++(int)
- {
- return *this;
- }
-
- template<typename T>
- void operator=(T val) const
- {
- pos = p(val, pos);
- }
-
- bool operator==(const pipe_output_iterator& other) const
- {
- return pos == other.pos;
- }
-
- bool operator!=(const pipe_output_iterator& other) const
- {
- return pos != other.pos;
- }
-
-private:
- mutable It pos;
- mutable OneManyPipe p;
-};
-
 template<typename OutputIterator, typename OneManyPipe>
 BOOST_CONCEPT_REQUIRES(
     ((OneManyPipeConcept<OneManyPipe>))

Added: sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator_fwd.hpp 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -0,0 +1,257 @@
+#ifndef BOOST_ITERATOR_PIPE_ITERATOR_FWD_HPP
+#define BOOST_ITERATOR_PIPE_ITERATOR_FWD_HPP
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/mpl/has_xxx.hpp>
+
+#include <boost/iterator/iterator_facade.hpp>
+#include <vector>
+
+#include <boost/iterator/pipe_concept.hpp>
+
+namespace boost
+{
+
+namespace detail
+{
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(max_output)
+
+ template<typename P, typename Enable = void>
+ struct pipe_output_storage;
+
+ template<typename P>
+ struct pipe_output_storage<P, typename ::boost::disable_if< has_max_output<P> >::type>
+ {
+ BOOST_CONCEPT_ASSERT((PipeConcept<P>));
+private:
+ typedef std::vector<typename P::output_type> Values;
+public:
+ typedef std::back_insert_iterator<Values> output_iterator;
+
+ const typename P::output_type& operator[](size_t i) const
+ {
+ return values[i];
+ }
+
+ size_t last_index() const
+ {
+ return values.size() - 1;
+ }
+
+ output_iterator out()
+ {
+ values.clear();
+ return std::back_inserter(values);
+ }
+
+ void update(output_iterator)
+ {
+ }
+
+ private:
+ Values values;
+ };
+
+ template<typename P>
+ struct pipe_output_storage<P, typename boost::enable_if< has_max_output<P> >::type>
+ {
+ BOOST_CONCEPT_ASSERT((PipeConcept<P>));
+private:
+ typedef typename P::output_type Value;
+public:
+ typedef Value* output_iterator;
+
+ const Value& operator[](size_t i) const
+ {
+ return values[i];
+ }
+
+ size_t last_index() const
+ {
+ return last;
+ }
+
+ output_iterator out()
+ {
+ return values;
+ }
+
+ void update(output_iterator u)
+ {
+ last = u - values - 1;
+ }
+
+ private:
+ Value values[P::max_output::value];
+ size_t last;
+ };
+}
+
+/** Iterator adapter that wraps a range to make it appear like a converted
+ * one, by converting it step-by-step as it is advanced. */
+template<typename It, typename Pipe>
+struct pipe_iterator
+ : iterator_facade<
+ pipe_iterator<It, Pipe>,
+ typename Pipe::output_type,
+ std::bidirectional_iterator_tag,
+ const typename Pipe::output_type
+ >
+{
+ BOOST_CONCEPT_ASSERT((InputIterator<It>));
+ BOOST_CONCEPT_ASSERT((PipeConcept<Pipe>));
+
+ BOOST_CONCEPT_ASSERT((Convertible<typename InputIterator<It>::value_type, typename Pipe::input_type>));
+
+ pipe_iterator() {} // singular
+
+ pipe_iterator(It begin_, It end_, It pos_, Pipe p_) : pos(pos_), begin(begin_), end(end_), index(0), p(p_)
+ {
+ if(pos != end)
+ {
+ std::pair<It, typename detail::pipe_output_storage<Pipe>::output_iterator> pair =
+ p.ltr(pos, end, values.out());
+ next_pos = pair.first;
+ values.update(pair.second);
+ }
+ }
+
+ It base() const
+ {
+ BOOST_CONCEPT_ASSERT((ForwardIterator<It>));
+
+ return pos;
+ }
+
+private:
+ typedef typename Pipe::output_type T;
+
+ friend class boost::iterator_core_access;
+
+ T dereference() const
+ {
+ return values[index];
+ }
+
+ void increment()
+ {
+ if(index != values.last_index())
+ {
+ index++;
+ }
+ else
+ {
+ pos = next_pos;
+ if(pos != end)
+ {
+ std::pair<It, typename detail::pipe_output_storage<Pipe>::output_iterator> pair =
+ p.ltr(pos, end, values.out());
+ next_pos = pair.first;
+ values.update(pair.second);
+ }
+ index = 0;
+ }
+ }
+
+ void decrement()
+ {
+ BOOST_CONCEPT_ASSERT((BidirectionalIterator<It>));
+
+ if(index != 0)
+ {
+ index--;
+ }
+ else
+ {
+ next_pos = pos;
+
+ std::pair<It, typename detail::pipe_output_storage<Pipe>::output_iterator> pair =
+ p.rtl(begin, pos, values.out());
+ pos = pair.first;
+ values.update(pair.second);
+
+ index = values.last_index();
+ }
+ }
+
+ bool equal(const pipe_iterator& other) const
+ {
+ return pos == other.pos && index == other.index;
+ }
+
+ It pos;
+ It next_pos;
+
+ It begin;
+ It end;
+ size_t index;
+
+ Pipe p;
+
+ detail::pipe_output_storage<Pipe> values;
+};
+
+/** Output Iterator adapter that wraps an output iterator to make one
+ * that will convert its output before pushing it to the wrapped iterator. */
+template<typename OutputIterator, typename OneManyPipe>
+struct pipe_output_iterator
+{
+ BOOST_CONCEPT_ASSERT((OutputIteratorConcept<OutputIterator, typename OneManyPipe::output_type>));
+ BOOST_CONCEPT_ASSERT((OneManyPipeConcept<OneManyPipe>));
+
+ typedef void difference_type;
+ typedef void value_type;
+ typedef pipe_output_iterator<OutputIterator, OneManyPipe>* pointer;
+ typedef pipe_output_iterator<OutputIterator, OneManyPipe>& reference;
+ typedef std::output_iterator_tag iterator_category;
+
+ pipe_output_iterator() {} // singular
+
+ pipe_output_iterator(OutputIterator pos_, OneManyPipe p_) : pos(pos_), p(p_)
+ {
+ }
+
+ OutputIterator base() const
+ {
+ return pos;
+ }
+
+ const pipe_output_iterator& operator*() const
+ {
+ return *this;
+ }
+
+ pipe_output_iterator& operator++()
+ {
+ return *this;
+ }
+
+ pipe_output_iterator& operator++(int)
+ {
+ return *this;
+ }
+
+ template<typename T>
+ void operator=(T val) const
+ {
+ pos = p(val, pos);
+ }
+
+ bool operator==(const pipe_output_iterator& other) const
+ {
+ return pos == other.pos;
+ }
+
+ bool operator!=(const pipe_output_iterator& other) const
+ {
+ return pos != other.pos;
+ }
+
+private:
+ mutable OutputIterator pos;
+ mutable OneManyPipe p;
+};
+
+} // namespace boost
+
+#endif

Modified: sandbox/SOC/2009/unicode/boost/unicode/graphemes.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/unicode/graphemes.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/unicode/graphemes.hpp 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -26,6 +26,8 @@
  * grapheme cluster boundary within a range of code points. */
 struct grapheme_boundary
 {
+ typedef char32 input_type;
+
     template<typename Iterator>
     bool operator()(Iterator begin, Iterator end, Iterator pos)
     {

Modified: sandbox/SOC/2009/unicode/boost/unicode/utf_codecs.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/unicode/utf_codecs.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/unicode/utf_codecs.hpp 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -80,6 +80,7 @@
  * of UTF-16 code units. */
 struct u16_encoder
 {
+ typedef char32 input_type;
         typedef char16 output_type;
     typedef mpl::int_<2> max_output;
         
@@ -122,6 +123,7 @@
  * a single code point. */
 struct u16_decoder
 {
+ typedef char16 input_type;
         typedef char32 output_type;
     typedef mpl::int_<1> max_output;
         
@@ -199,6 +201,8 @@
  * point boundary within a range of UTF-16 code units. */
 struct u16_boundary
 {
+ typedef char16 input_type;
+
     template<typename In>
     bool operator()(In begin, In end, In pos)
     {
@@ -214,6 +218,7 @@
  * of UTF-8 code units. */
 struct u8_encoder
 {
+ typedef char32 input_type;
         typedef char output_type;
     typedef mpl::int_<4> max_output;
         
@@ -255,6 +260,7 @@
  * a single code point. */
 struct u8_decoder
 {
+ typedef char input_type;
         typedef char32 output_type;
     typedef mpl::int_<1> max_output;
 
@@ -378,6 +384,8 @@
  * point boundary within a range of UTF-8 code units. */
 struct u8_boundary
 {
+ typedef char input_type;
+
     template<typename In>
     bool operator()(In begin, In end, In pos)
     {
@@ -425,6 +433,7 @@
  * \c u8_decoder depending on the value type of the input range. */
 struct utf_decoder
 {
+ typedef char32 input_type;
     typedef char32 output_type;
     typedef mpl::int_<1> max_output;
 
@@ -433,7 +442,16 @@
     template<typename Iterator, typename Enable = void>
     struct decoder
     {
- typedef one_many_pipe< cast_pipe<output_type> > type;
+ };
+
+ template<typename Iterator>
+ struct decoder<Iterator, typename enable_if<
+ detail::is_u32<
+ typename std::iterator_traits<Iterator>::value_type
+ >
+ >::type>
+ {
+ typedef one_many_pipe< cast_pipe<char32> > type;
     };
     
     template<typename Iterator>
@@ -477,16 +495,25 @@
  * \c u8_boundary depending on the value type of the input range. */
 struct utf_boundary
 {
+ typedef char32 input_type;
+
     template<typename In>
     bool operator()(In begin, In end, In pos)
     {
- return impl(begin, end, pos, 0);
+ return impl(begin, end, pos, (void*)0);
     }
     
 #ifndef BOOST_UNICODE_DOXYGEN_INVOKED
 private:
     template<typename In>
- bool impl(In, In, In, ...)
+ bool impl(
+ In begin, In end, In pos,
+ typename enable_if<
+ detail::is_u32<
+ typename std::iterator_traits<In>::value_type
+ >
+ >::type*
+ )
     {
         return true;
     }

Modified: sandbox/SOC/2009/unicode/libs/unicode/doc/Jamfile.v2
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/doc/Jamfile.v2 (original)
+++ sandbox/SOC/2009/unicode/libs/unicode/doc/Jamfile.v2 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -27,7 +27,8 @@
 
 doxygen autodoc
     :
- [ path.glob-tree ../../../boost/unicode ../../../boost/iterator : *.hpp : .svn detail ]
+ [ path.glob-tree ../../../boost/iterator : pipe_*.hpp consumer_*.hpp : .svn detail ]
+ [ path.glob-tree ../../../boost/unicode : *.hpp : .svn detail ]
         ../../../boost/cuchar.hpp
         :
         <doxygen:param>EXTRACT_ALL=YES

Modified: sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/BoundaryChecker.xml
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/BoundaryChecker.xml (original)
+++ sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/BoundaryChecker.xml 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -8,7 +8,7 @@
   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
   -->
   <param name="BoundaryChecker" role="model of BoundaryChecker" />
- <param name="In" role="model of Bidirectional Iterator" />
+ <param name="In" role="model of Bidirectional Iterator with elements convertible to input_type" />
 
   <models-sentence>
     The type <arg num="1" /> must be a model of <self/>.
@@ -32,6 +32,15 @@
       <type name="In" />
     </sample-value>
   </notation>
+
+ <associated-type name="input_type">
+ <get-member-type name="input_type">
+ <type name="BoundaryChecker" />
+ </get-member-type>
+ <description>
+ <simpara>The type of elements the boundary checker analyzes.</simpara>
+ </description>
+ </associated-type>
 
   <valid-expression name="Construction">
     <construct template-parameters="">

Modified: sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/Consumer.xml
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/Consumer.xml (original)
+++ sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/Consumer.xml 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -8,7 +8,7 @@
   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
   -->
   <param name="Consumer" role="model of Consumer" />
- <param name="In" role="model of Input Iterator" />
+ <param name="In" role="model of Bidirectional Iterator with elements convertible to input_type" />
 
   <models-sentence>
     The type <arg num="1" /> must be a model of <self/>.
@@ -32,6 +32,15 @@
       <type name="In" />
     </sample-value>
   </notation>
+
+ <associated-type name="input_type">
+ <get-member-type name="input_type">
+ <type name="Consumer" />
+ </get-member-type>
+ <description>
+ <simpara>The type of elements the consumer consumes.</simpara>
+ </description>
+ </associated-type>
   
   <valid-expression name="Construction">
     <construct template-parameters="">

Modified: sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/OneManyPipe.xml
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/OneManyPipe.xml (original)
+++ sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/OneManyPipe.xml 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -8,8 +8,8 @@
   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
   -->
   <param name="Pipe" role="model of OneManyPipe" />
- <param name="In" role="value input type" />
- <param name="Out" role="model of Output Iterator" />
+ <param name="In" role="model of Convertible&lt;input_type&gt;" />
+ <param name="Out" role="model of OutputIterator&lt;output_type&gt;" />
 
   <models-sentence>
     The type <arg num="1" /> must be a model of <self/>.
@@ -41,6 +41,15 @@
     </sample-value>
   </notation>
 
+ <associated-type name="input_type">
+ <get-member-type name="input_type">
+ <type name="Pipe" />
+ </get-member-type>
+ <description>
+ <simpara>The type of elements the pipe converts from.</simpara>
+ </description>
+ </associated-type>
+
   <associated-type name="output_type">
     <get-member-type name="output_type">
     <type name="Pipe" />

Modified: sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/Pipe.xml
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/Pipe.xml (original)
+++ sandbox/SOC/2009/unicode/libs/unicode/doc/concepts/Pipe.xml 2009-07-30 13:13:02 EDT (Thu, 30 Jul 2009)
@@ -8,8 +8,8 @@
   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
   -->
   <param name="Pipe" role="model of Pipe" />
- <param name="In" role="model of Input Iterator" />
- <param name="Out" role="model of Output Iterator" />
+ <param name="In" role="model of Bidirectional Iterator with elements convertible to input_type" />
+ <param name="Out" role="model of OutputIterator&lt;output_type&gt;" />
 
   <models-sentence>
     The type <arg num="1" /> must be a model of <self/>.
@@ -40,6 +40,15 @@
       <type name="Out" />
     </sample-value>
   </notation>
+
+ <associated-type name="input_type">
+ <get-member-type name="input_type">
+ <type name="Pipe" />
+ </get-member-type>
+ <description>
+ <simpara>The type of elements the pipe converts from.</simpara>
+ </description>
+ </associated-type>
 
   <associated-type name="output_type">
     <get-member-type name="output_type">


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