我正在尝试在地图中存储std :: string并收到以下错误
error: invalid initialization of reference of type ‘boost::any&’ from expression of type ‘std::string’
代码如下
#include "boost/any.hpp"
#include <iostream>
#include <map>
using namespace std;
map<string, boost::any> m;
void putObject(string name, boost::any& value)
{ m[name]= value; }
boost::any getObject(string name) { return m[name]; }
int main()
{
string s = "a";
cout << "Original Address: " << &s << endl;
putObject(s, s);
return 0;
}