8
我試圖將foo
對象存儲到std::reference_wrapper
中,但是最終出現了我不明白的編譯器錯誤。在地圖中存儲引用
#include <functional>
#include <map>
struct foo
{
};
int main()
{
std::map< int, std::reference_wrapper<foo> > my_map;
foo a;
my_map[ 0 ] = std::ref(a);
}
編譯器錯誤是相當漫長的,但它歸結爲:
error: no matching function for call to ‘std::reference_wrapper<foo>::reference_wrapper()’
我究竟在做什麼錯?
的std ::的reference_wrapper沒有默認構造函數 – 2015-03-31 08:14:08