Ticket #3124: fix3124.patch

File fix3124.patch, 4.0 KB (added by Eric Niebler, 13 years ago)

hopefully fix the problem with copying a singular iterator

  • boost/xpressive/detail/utility/sequence_stack.hpp

     
    173173        this->begin_ = this->curr_ = this->end_ = 0;
    174174    }
    175175
    176     template<bool Fill>
    177     T *push_sequence(std::size_t count, mpl::bool_<Fill>)
     176    T *push_sequence(std::size_t count)
    178177    {
    179178        // This is the ptr to return
    180179        T *ptr = this->curr_;
     
    192191            return this->grow_(count);
    193192        }
    194193
    195         if(Fill)
    196         {
    197             std::fill_n(ptr, count, T());
    198         }
    199 
    200194        return ptr;
    201195    }
    202196
    203     T *push_sequence(std::size_t count)
     197    template<typename U>
     198    T *push_sequence(std::size_t count, U const &u)
    204199    {
    205         return this->push_sequence(count, mpl::true_());
     200        T *ptr = this->push_sequence(count);
     201        std::fill_n(ptr, count, u);
     202        return ptr;
    206203    }
    207204
    208205    void unwind_to(T *ptr)
     
    229226    }
    230227};
    231228
    232 typedef mpl::false_ no_fill_t;
    233 no_fill_t const no_fill = {};
    234 
    235229}}} // namespace boost::xpressive::detail
    236230
    237231#if defined(_MSC_VER) && (_MSC_VER >= 1020)
  • boost/xpressive/detail/core/state.hpp

     
    289289        this->context_.results_ptr_ = &what;
    290290        this->context_.traits_ = impl.traits_.get();
    291291        this->mark_count_ = impl.mark_count_ + 1;
    292         this->sub_matches_ = this->extras_->sub_match_stack_.push_sequence(total_mark_count);
     292        this->sub_matches_ = this->extras_->sub_match_stack_.push_sequence(total_mark_count, detail::sub_match_impl_default());
    293293        this->sub_matches_ += impl.hidden_mark_count_;
    294294
    295295        // initialize the match_results struct
     
    329329{
    330330    memento<BidiIter> mem =
    331331    {
    332         state.extras_->sub_match_stack_.push_sequence(state.mark_count_, no_fill)
     332        state.extras_->sub_match_stack_.push_sequence(state.mark_count_)
    333333      , state.context_.results_ptr_->nested_results().size()
    334334      , state.action_list_.next
    335335      , state.action_list_tail_
  • boost/xpressive/detail/core/sub_match_impl.hpp

     
    2323// need is trivial constructor/destructor. (???)
    2424
    2525///////////////////////////////////////////////////////////////////////////////
     26// sub_match_impl_default
     27//
     28struct sub_match_impl_default
     29{
     30};
     31
     32///////////////////////////////////////////////////////////////////////////////
    2633// sub_match_impl
    2734//
    2835template<typename BidiIter>
     
    4047      , zero_width_(false)
    4148    {
    4249    }
     50
     51    sub_match_impl &operator =(sub_match_impl_default const &)
     52    {
     53        this->matched = false;
     54        this->repeat_count_ = 0;
     55        this->zero_width_ = false;
     56        return *this;
     57    }
    4358};
    4459
    4560}}} // namespace boost::xpressive::detail
  • boost/xpressive/match_results.hpp

     
    410410        {
    411411            extras_type &extras = this->get_extras_();
    412412            std::size_t size = that.sub_matches_.size();
    413             detail::sub_match_impl<BidiIter> *sub_matches = extras.sub_match_stack_.push_sequence(size);
     413            detail::sub_match_impl<BidiIter> *sub_matches = extras.sub_match_stack_.push_sequence(size, detail::sub_match_impl_default());
    414414            detail::core_access<BidiIter>::init_sub_match_vector(this->sub_matches_, sub_matches, size, that.sub_matches_);
    415415
    416416            // BUGBUG this doesn't share the extras::sequence_stack