[Boost-bugs] [Boost C++ Libraries] #11188: can not use repeat(int)[] with std::ref and phoenix::ref

Subject: [Boost-bugs] [Boost C++ Libraries] #11188: can not use repeat(int)[] with std::ref and phoenix::ref
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-04-14 08:37:31


#11188: can not use repeat(int)[] with std::ref and phoenix::ref
------------------------------+---------------------
 Reporter: vveesskkoo@… | Owner: djowel
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: spirit
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: repeat |
------------------------------+---------------------
 Debian libboost-dev 1.55[[BR]]
 When trying to compile a rule containing:

 {{{
 qi::repeat(std::ref(_n))[some_action]
 }}}

 the compiler complains:
 /usr/include/boost/spirit/home/qi/directive/repeat.hpp:88:40: error: use
 of deleted function ‘std::reference_wrapper<_Tp>::reference_wrapper(_Tp&&)
 [with _Tp = int]’[[BR]]
 T start() const { return '''type(0);''' }

 In this situation qi:repeat (repeat.hpp:88:40) tries to create an iterator
 from[[BR]]
 std::reference_wrapper<>(rhs_value) which is not possible as a reference
 is needed!

 As a temporary workaround I used the following help type:

 {{{
 template<typename T>
 class ref_rhs: public std::reference_wrapper<T> {
     private:
         T _rhval;
     public:
         using std::reference_wrapper<T>::reference_wrapper; // inherit
 constructors

         ref_rhs(T&& rhs):
             std::reference_wrapper<T>(_rhval),
             _rhval(rhs)
         {}
 };
 }}}



 and the call: qi::repeat(ref_rhs<T>(_n))[] works as expected.

 May be qi:repeat should iterate internally with integers rather than with
 iterators as the documentation says that in the call qi::repeat(_n) _n
 must be convertible to int anyway.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11188>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC