如何初始化 Boost 日期?
页面
http://www.boost。 org/doc/libs/1_42_0/doc/html/date_time/gregorian.html#date_construction
解释了您可以初始化 使用这种调用提高日期:
date d(2002, Jan, 10);
但是当我尝试这样做时,编译器不知道“Jan”。
它确实适用于:
date d(2002, 1, 10);
编辑:
#include <boost/date_time/gregorian/gregorian.hpp>
..
{
using namespace boost::gregorian;
date limit_date(2010,Apr,1);
date fake_date(2010,2,1);
if (fake_date>limit_date)
{
...
}
}
The page
http://www.boost.org/doc/libs/1_42_0/doc/html/date_time/gregorian.html#date_construction
explains that you can initialize a Boost date with this kind of call:
date d(2002, Jan, 10);
But when I try that, the compiler doesn't know 'Jan'.
It does work with:
date d(2002, 1, 10);
EDIT:
#include <boost/date_time/gregorian/gregorian.hpp>
..
{
using namespace boost::gregorian;
date limit_date(2010,Apr,1);
date fake_date(2010,2,1);
if (fake_date>limit_date)
{
...
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您错过了包含所需的命名空间?我不能确切地说是哪一个,因为你没有发布完整的代码,但我可以假设,它可能是这样的:
或
更新:
Jan 的辩护:
Maybe you missed including of needed namespace? I can't say which one exactly, because you didn't post whole code, but I can suppose, that it can be something like:
or
Update:
Defenition of Jan:
好吧,我找到了(愚蠢的)解决方案:我只是忘记将 date_time 链接到我自己的库...
由于 boost::date_time 的某些部分不需要显式链接,因此它们起作用了。这就是为什么我没有探索这种方式。
感谢 Jan 的帮助和枚举!
OK, I found the (silly) solution : I just forgot to link date_time to my own library...
As some parts of boost::date_time don't require an explicit linking, they worked. That's why I didn't explore this way.
Thanks Jan for help and the enum !