Using Boost.Hana causes hard compiler errors in some attribute propagation paths

未关闭
#336 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
cpp
领域
backend

调研方向

Start in parser.hpp at the semantic action dispatch and attribute assembling paths around the two locations shown in the issue. Check how tuple operations follow BOOST_PARSER_USE_HANA_TUPLE elsewhere, then build the Mutable Symbol Tables tutorial example with Hana tuples. Done means the example builds and the existing std::tuple path still works.

由索引模型根据 Issue 内容生成。

描述

It seems semantic action dispatch and attribute "assembling" is hardcoded to use std::tuple ignoring BOOST_PARSER_USE_HANA_TUPLE flag.

Tutorial's example for Mutable Symbol Tables fails during build if uses Hana tuples (as current version of tutorial does).

Here is brief patch, which most likely don't follow library conventions but should make this issue visible:

diff --git a/parser.hpp b/parser.hpp
index 6a32dfb..18e8f51 100644
--- a/parser.hpp
+++ b/parser.hpp
@@ -3548,9 +3548,17 @@ namespace boost { namespace parser {
             };
             detail::skip(first, last, skip, flags);

+#if defined(BOOST_PARSER_USE_HANA_TUPLE)
+            boost::hana::unpack(parsers_, [&try_parser](auto&&... args) {
+#else
             std::apply([&try_parser](auto&&... args) {
+#endif
                 ((try_parser(args)), ...);
+#if defined(BOOST_PARSER_USE_HANA_TUPLE)
+            });
+#else
             }, parsers_);
+#endif

             if (!done)
                 success = false;
@@ -4608,9 +4616,18 @@ namespace boost { namespace parser {

             auto const parsers_and_indices =
                 detail::hl::zip(parsers_, indices, merged, backtracking{});
+#if defined(BOOST_PARSER_USE_HANA_TUPLE)
+            boost::hana::unpack(
+                parsers_and_indices, [&use_parser](auto&&... args) {
+#else
             std::apply([&use_parser](auto&&... args) {
+#endif
                 ((use_parser(args)), ...);
+#if defined(BOOST_PARSER_USE_HANA_TUPLE)
+            });
+#else
             }, parsers_and_indices);
+#endif
         }

         template<bool AllowBacktracking, typename Parser>
主要语言
C++
星标
185
派生
28
平均合并
20 小时 44 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

boostorg/parser 的其他 Issue

查看 boostorg/parser 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。