我尝试将一个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()’
我到底做错了什么?