From ba5e4c30c65fe7e00abdc3ee2e87b305b0678b00 Mon Sep 17 00:00:00 2001 From: Pavol Droba Date: Tue, 17 Jun 2008 21:58:58 +0000 Subject: [PATCH] fixed the rle example crash [SVN r46463] --- string/example/rle_example.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/string/example/rle_example.cpp b/string/example/rle_example.cpp index 26ec5b8..9e52b96 100644 --- a/string/example/rle_example.cpp +++ b/string/example/rle_example.cpp @@ -114,10 +114,13 @@ public: result_type operator()( const ReplaceT& Replace ) const { SeqT r; - r.push_back( repeat_mark() ); - r.push_back( *(Replace.begin()) ); - r.push_back( value_type( Replace.size() ) ); - + if(!Replace.empty()) + { + r.push_back( repeat_mark() ); + r.push_back( *(Replace.begin()) ); + r.push_back( value_type( Replace.size() ) ); + } + return r; } }; @@ -183,14 +186,18 @@ public: template< typename ReplaceT > result_type operator()( const ReplaceT& Replace ) const { - // extract info - typename ReplaceT::const_iterator It=Replace.begin(); - - value_type Value=*(++It); - value_type Repeat=*(++It); - SeqT r; - for( value_type Index=0; Index