【问题标题】:boost date missing template arguments before提升日期之前缺少模板参数
【发布时间】:2015-09-12 02:53:30
【问题描述】:

当我使用 boost 编译一个简单的日期解析测试时,我得到了一个 missing template arguments,代码如下:

#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/gregorian/parsers.hpp"

boost::date_time::date test = boost::gregorian::from_us_string("07-Sep-2010");

编译器抱怨 error: missing template arguments before ‘test’ boost::date_time::date test = boost::gregorian::from_us_string("07-Sep-2010");

我不明白我应该提供哪些模板参数,或者为什么我应该首先提供模板参数。就我的口味而言,这似乎是一个有点多的样板代码:)

【问题讨论】:

    标签: c++ boost boost-date-time


    【解决方案1】:

    应该是boost::gregorian::date 而不是boost::date_time::date。 除此之外,您可以使用

    auto test = boost::gregorian::from_us_string("07-Sep-2010");
    

    如果您使用的是 C++11。

    【讨论】:

      猜你喜欢
      • 2018-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多