我想樹的密鑰綁定的功能,使用標準的代碼(約祖蒂斯), 但Visual Studio 2010的警告(和崩潰,當我運行它):爲什麼我會用std :: bind()獲取「本地臨時返回地址」警告?
... /功能(447):警告C4172:本地臨時
代碼返回地址是:
void print(int x) { ... }
using namespace std;
map<int, float> m;
for_each(m.begin(), m.end(),
bind(print,
bind(&map<int,float>::value_type::first, placeholders::_1)));
這段代碼似乎罰款以外的其他編譯器進行工作。
是否有任何隱藏的內部窗口執行綁定導致此錯誤?
一個lambda可能更容易:'[](地圖 :: VALUE_TYPE對){打印(pair.first);}' –
MSalters
vs2012說錯誤C2780:!enable_if <性病:: is_same <_Ty1,_Ty2> ::值,標準:: _ Bind, _Vx0_t,_Vx1_t,_Vx2_t,_Vx3_t,_Vx4_t >> :: type std :: bind(_Rx(__thiscall _Farg0 :: * const)(_V0_t,_V1_t,_V2_t,_V3_t,_V4_t)volatile const,_Vx0_t &&,_ Vx1_t &&,_ Vx2_t && ,_Vx3_t &&,_ Vx4_t &&)':需要6個參數 - 提供2個參數。你使用了什麼其他編譯器? –
doctorlove
@doctorlove我用vs2010。那麼,vs2012有什麼問題?這段代碼應該編譯好! –