使用""或<>包含boost头文件

dim*_*mba 2 c++ compiler-construction coding-style conventions c-preprocessor

为什么元组文档要使用,例如:

#include "boost/tuple/tuple.hpp"
Run Code Online (Sandbox Code Playgroud)

并不是

#include <boost/tuple/tuple.hpp>
Run Code Online (Sandbox Code Playgroud)

我知道我的代码不可能有一个名为"boost/tuple/tuple.hpp"的文件,但使用include <>明确表示不要查看curent目录.

那是什么原因?

小智 7

使用<>并不意味着"不要查看当前目录" - 这意味着查看实现定义的位置,然后查看其他位置,同时实现定义.这两者中的任何一个或两者都不是当前目录.这是C++标准中比较无用的部分之一.

  • 我确切知道它的作用.在我的机器上工作. (3认同)
  • 我怀疑绝大多数C和C++程序员都不知道#include实际上为他们的具体实现做了什么 - 我知道我没有. (2认同)

wal*_*lyk 5

历史意义<somefile>是看系统标准的地方.使用"somefile"它意味着查看当前目录,以及其他一些地方.