变量隐藏在Boost Phoenix的嵌套let块中

Variable hiding within nested let blocks in Boost Phoenix

本文关键字:嵌套 let 块中 Phoenix 隐藏 Boost 变量      更新时间:2023-10-16

我在Boost Phoenix中嵌套let块时遇到了一些麻烦,当"内部"局部变量隐藏了"外部"局部变量。即使使用文档中的"Visibility"示例,如下所示:

#include <iostream>
#include <boost/phoenix.hpp>
namespace phoenix = boost::phoenix;
using namespace phoenix::local_names;
int main(int argc, char *argv[])
{
  phoenix::let(_x = 1, _y = ", World")
  [
    phoenix::let(_x = "Hello") // hides the outer _x
    [
      std::cout << _x << _y // prints "Hello, World"
    ]
  ]();
  return 0;
}

我收到以:

开头的错误
GCC:   "error: function returning an array"
Clang: "error: function cannot return array type 'result_type' (aka 'char [6]')"

有人知道我如何在Phoenix的内部let块范围内"影子"这样的变量吗?我目前使用Ubuntu 13.04与GCC版本4.8快照;铿锵声3.2;增加1.49;以及Boost 1.53。

这绝对是Phoenix中的一个bug。以下编译:

int y = 0;
int x = (phoenix::let(_a = 1, _b = 2)[phoenix::let(_b = _1)[ _a ]])(y);

int y = 0;
int x = (phoenix::let(_a = 1, _b = 2)[phoenix::let(_b = 3)[ _a ]])(y);

怪异。你可以在https://svn.boost.org/trac/boost/上提交bug(点击"New Ticket")吗?谢谢。(注意:我不是维护人员)