Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
X3: Fixed container of move only types with sequence
  • Loading branch information
Kojoley committed Feb 26, 2019
commit 8bd9b6ece40f9324a902bb0f726e785ffa689fce
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <boost/fusion/include/front.hpp>
#include <boost/fusion/include/back.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <iterator> // for std::make_move_iterator

namespace boost { namespace spirit { namespace x3 { namespace detail
{
Expand Down Expand Up @@ -262,7 +263,8 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
Attribute rest;
bool r = parser.parse(first, last, context, rcontext, rest);
if (r)
traits::append(attr, rest.begin(), rest.end());
traits::append(attr, std::make_move_iterator(rest.begin()),
std::make_move_iterator(rest.end()));
return r;
}

Expand Down
5 changes: 4 additions & 1 deletion include/boost/spirit/home/x3/operator/detail/sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_same.hpp>

#include <iterator> // for std::make_move_iterator

namespace boost { namespace spirit { namespace x3
{
template <typename Left, typename Right>
Expand Down Expand Up @@ -445,7 +447,8 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
{
return false;
}
traits::append(attr, traits::begin(attr_), traits::end(attr_));
traits::append(attr, std::make_move_iterator(traits::begin(attr_)),
std::make_move_iterator(traits::end(attr_)));
return true;
}

Expand Down
8 changes: 8 additions & 0 deletions test/x3/sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <string>
#include <iostream>
#include "test.hpp"
#include "utils.hpp"

int
main()
Expand Down Expand Up @@ -491,5 +492,12 @@ main()
#endif
}

{ // test move only types
using boost::spirit::x3::eps;
std::vector<move_only> v;
BOOST_TEST(test_attr("ssszs", *synth<move_only> >> 'z' >> synth<move_only>, v));
BOOST_TEST_EQ(v.size(), 4);
}

return boost::report_errors();
}