Variants are not supported by parsers that lazily synthesize attributes e.g. `string`
- Dominant language
- C++
- Stars
- 432
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
If parser lazily synthesize attribute (e.g. `string`) it actually exposes a pair of iterators that will be used to build an attribute inplace by `qi::assign_to`/`x3::move_to` call.
But neither `x3::move_to(first, last, attr)` nor `qi::assign_to(first, last, attr)` support variants. So next code fails to compile while logically valid:
```cpp
#include
#include
#include
#include
int main()
{
typedef boost::variant attribute_type;
#if X3
{
namespace x3 = boost::spirit::x3;
x3::rule r;
auto start = r = x3::string("foo");
// need to have a parse call to instantiate the templates
attribute_type a;
std::string s = "foo";
x3::parse(s.cbegin(), s.cend(), start, a);
}
#else
{
namespace qi = boost::spirit::qi;
qi::rule r;
r = qi::string("foo");
}
#endif
return 0;
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by compiling the reproducer in the issue with both the X3 and Qi paths enabled. Read the implementations of x3::move_to and qi::assign_to, focusing on how they handle iterator pairs and boost::variant attributes. Done means the shown examples compile successfully for both parser implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100