我在Visual Studio 2013 Express中使用了boost.
Visual Studio #include <boost/filesystem.hpp>在"调试"模式下查找,但不在"发布"模式下查找.
当我尝试在发布模式下编译时,它说:
Error 1 error C1083: Cannot open include file: 'boost/filesystem.hpp': No such file or directory
当我右键单击#include指令手动打开文件时,它在Debug配置中工作,但同样不在Release中,它说:
File 'boost/filesystem.hpp' not found in current source file's directory or in build system paths.
我检查了构建配置和
两种配置都相同.
我是否需要编辑"构建系统路径",如错误所示?我认为这就是上面三个选项的作用.
还有什么可能导致这个问题?
我有一个带有自定义比较器的STL映射,我希望将其传递给函数,但该函数无法识别自定义比较器.
试图在主要功能中访问地图.
我在代码中列出了两次尝试.
#include <iostream>
#include <string>
#include <map>
// Error: cmpByStringLength is not recognized (both times)
void funcOut(std::map<std::string, int, cmpByStringLength> myMap)
{
for (std::map<std::string, int, cmpByStringLength>::iterator it = myMap.begin(); it != myMap.end(); ++it)
{
std::cout << it->first << " => " << it->second << std::endl;
}
}
int main()
{
// Reverse sort by length
struct cmpByStringLength {
bool operator()(const std::string& a, const std::string& b) const {
return a.length() > b.length();
}
};
std::map<std::string, int, cmpByStringLength> myMap;
myMap.emplace("String 1", …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来使这个if语句更有效或至少更短.我在想,无论是i或j必须是,(n - 1)或两者兼有(n - 2).
if ((i == (n - 1) && j == (n - 1)) ||
(i == (n - 1) && j == (n - 2)) ||
(i == (n - 2) && j == (n - 1)) ||
(i == (n - 2) && j == (n - 2)))
{
// Code
}
Run Code Online (Sandbox Code Playgroud)