关于boost

delphiwcdj 2011-02-24 10:57:55
使用string类为什么不需要头文件?在boost头文件中似乎没有找到。

#include <iostream>
#include <boost/regex.hpp>
//#include <string>

int main()
{
std::string s = "wcdj";
std::cout<<s<<std::endl;

return 0;
}
...全文
217 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
delphiwcdj 2011-02-25
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 thefirstz 的回复:]

在boost/regex.hpp中后面会引用boost\regex\v4\cregex.hpp文件,该文件里有下面内容:
C# code
#if defined(__cplusplus)
/*
* C++ high level wrapper goes here:
*/
#include <string>
#include <vector>
namespace boost{

#ifde……
[/Quote]
谢谢!
不过是boost/regex.hpp,不是boost/regex.h哦,boost/regex.h中有引用boost\regex\v4\cregex.hpp
boost里面肯定包含有<string>,只是boost的头文件比较多,不太好找。
昵称很不好取 2011-02-25
  • 打赏
  • 举报
回复
在boost/regex.hpp中后面会引用boost\regex\v4\cregex.hpp文件,该文件里有下面内容:
#if defined(__cplusplus)
/*
* C++ high level wrapper goes here:
*/
#include <string>
#include <vector>
namespace boost{

#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable: 4103)
#endif
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
昵称很不好取 2011-02-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 thefirstz 的回复:]
这和boost没什么关系,有iostream就可以了
[/Quote]
研究了下,我搞错了,没有boost头文件声明string是可以的,但是cout就不行了

[Quote=引用 3 楼 loaden 的回复:]
因为boost中使用了std的头文件。你注释掉:#include <boost/regex.hpp>
试试。
[/Quote]
「已注销」 2011-02-24
  • 打赏
  • 举报
回复
因为boost中使用了std的头文件。你注释掉:#include <boost/regex.hpp>
试试。
jieao111 2011-02-24
  • 打赏
  • 举报
回复
这个问题太牛逼
昵称很不好取 2011-02-24
  • 打赏
  • 举报
回复
这和boost没什么关系,有iostream就可以了

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧