我无法弄清楚如何使用a 获得std::string引用.根据以下链接,我知道我需要超载.std::unordered_mapstd::reference_wrapperoperator==
为什么不能在`std :: reference_wrapper`s中推导出模板实例?
但是,我无法弄清楚如何编写operator==它将需要一个const std::reference_wrapper.如果包装器不是const,那就没问题了.
使用char代替std::string工作正常(不需要重载operator==).
码:
#include <iostream>
#include <unordered_map>
#include <functional>
bool operator==(const std::reference_wrapper<std::string> lhs,
const std::reference_wrapper<std::string> rhs)
{
return std::equal_to<std::string>()(lhs.get(), rhs.get());
}
int main(){
char chr('a');
std::string str("b");
int num(1);
// this works (char)
std::unordered_map<std::reference_wrapper<char>, int, std::hash<char>> charMap;
std::pair<std::reference_wrapper<char>, int> charPair(chr , num);
charMap.insert(charPair);
std::cout << "charMap works. Output: " << charMap[chr] << std::endl;
// does not work (std::string)
std::unordered_map<std::reference_wrapper<std::string>, …Run Code Online (Sandbox Code Playgroud) 我正在测试MongoDB 3.0.5并且无法运行./mongod或./mongo并出现以下错误:
$ ./mongod
./mongod: symbol lookup error: ./mongod: undefined symbol: FIPS_mode_set
Run Code Online (Sandbox Code Playgroud)
我安装了libssl.so.0.9.8,这似乎是必需的依赖项.
有谁知道如何解决此错误?
提前致谢.