私はちょうど今奇妙な問題に遭遇しました。
ソースコードは次のように単純で自明です。
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
using namespace std::tr1;
template<class T_>
void show_size(T_ coll)
{
cout << coll.size();
}
int main()
{
vector<int> coll;
coll.push_back(1);
show_size(ref(coll));
return 0;
}
VC ++2010のレポート:
エラーC2039:'size':は'std :: tr1 :: reference_wrapper<_Ty>'のメンバーではありません
ご存知のように、reference_wrapperは自動的にその基になるタイプに変換できます。これがですvector<int>
。なぜそのような単純なコードは無効なのですか?