小编cor*_*ped的帖子

如何将std :: string转换为boost :: gregorian :: date?

我试图将转换std::stringboost::gregorian::date这样的:

using namespace boost::gregorian;

std::string str = "1 Mar 2012";
std::stringstream ss(str);
date_input_facet *df = new date_input_facet("%e %b %Y");
ss.imbue(std::locale(ss.getloc(), df));
date d;

ss >> d;  //conversion fails to not-a-date-time

std::cout << "'" << d << "'" << std::endl;  //'not-a-date-time'
Run Code Online (Sandbox Code Playgroud)

但如果字符串包含"2012年3月1日",则转换成功.

如何将"2012年3月1日"等字符串转换为等效字符串boost::gregorian::date

c++ boost boost-date-time

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

timerfd和读取

我有应用程序,定期(通过计时器)检查一些数据存储.
像这样:

#include <iostream>
#include <cerrno>
#include <cstring>
#include <cstdlib>
#include <sys/fcntl.h>
#include <unistd.h>

// EPOLL & TIMER
#include <sys/epoll.h>
#include <sys/timerfd.h>

int main(int argc, char **argv)
{
    /* epoll instance */
    int efd = epoll_create1(EPOLL_CLOEXEC);

    if (efd < 0)
    {
        std::cerr << "epoll_create error: " << strerror(errno) << std::endl;
        return EXIT_FAILURE;
    }

    struct epoll_event ev;
    struct epoll_event events[128];

    /* timer instance */
    int tfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);

    struct timespec ts;
    // first expiration in 3. seconds after program start …
Run Code Online (Sandbox Code Playgroud)

c++ epoll timeout timer

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

标签 统计

c++ ×2

boost ×1

boost-date-time ×1

epoll ×1

timeout ×1

timer ×1