小编Thu*_*ext的帖子

Visual Studio在发布模式下找不到boost包含文件(在调试中工作)

我在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.

我检查了构建配置和

  • C/C++ - >常规 - >"其他包含目录"
  • 链接器 - >常规 - >"其他库目录"
  • 链接器 - >输入 - >"附加依赖项"

两种配置都相同.

我是否需要编辑"构建系统路径",如错误所示?我认为这就是上面三个选项的作用.

还有什么可能导致这个问题?

c++ boost include visual-studio-2013

7
推荐指数
1
解决办法
3494
查看次数

使用自定义比较器传递地图功能

我有一个带有自定义比较器的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)

c++ dictionary function c++11

1
推荐指数
1
解决办法
863
查看次数

如何使用多个条件的if语句更短?

我正在寻找一种方法来使这个if语句更有效或至少更短.我在想,无论是ij必须是,(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)

c++ performance if-statement

1
推荐指数
1
解决办法
77
查看次数