0

「内部」ローカル変数が「外部」ローカル変数を隠している場合、Boost Phoenix のネストされた let ブロックで問題が発生します。ドキュメントhereの「可視性」の例でも、ここに示されています。

#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]')"

フェニックスのインナーレットブロックのスコープ内でそのような変数を「シャドウ」する方法を知っている人はいますか? 現在、GCC バージョン 4.8 スナップショットで Ubuntu 13.04 を使用しています。クラン 3.2; ブースト 1.49; Boost 1.53も。

4

1 に答える 1