2013-05-06 26 views
0

當「內部」局部變量隱藏「外部」局部變量時,我在Boost Phoenix中嵌套的let塊出現問題。即使從文檔here的「能見度」的例子,如下所示:變量隱藏在Boost Phoenix中的嵌套let塊中

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

有誰知道我能「影子」這樣的範圍內變化菲尼克斯的一個內部區塊?我目前正在使用Ubuntu 13.04和GCC版本4.8快照; Clang 3.2;升壓1.49;並且還提升了1.53。

回答

2

這絕對是鳳凰城的一個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/處提交錯誤(點擊「新建工單」)。謝謝。 (注:我不是維護者。)

+0

當然可以。感謝您的意見。 – user2023370 2013-05-07 20:43:18

+0

該錯誤現已提交[此處](https://svn.boost.org/trac/boost/ticket/8564) – user2023370 2013-05-11 23:42:25