草庐IT

Call-time

全部标签

C++ time_t问题

我在使用C++(VS2008)进行日期管理时遇到了问题。根据MSDNspecifications,time_t代表:自1970年1月1日0:00UTC以来的秒数因此,我写了这段代码:#include#includetime_tGetDate(intyear,intmonth,intday,inthour,intmin,intsec){time_trawtime;structtm*timeinfo;time(&rawtime);timeinfo=gmtime(&rawtime);timeinfo->tm_year=year-1900;timeinfo->tm_mon=month-1;ti

c++ - 视觉口齿不清 : how to call functions in external C++ DLL

我有一个我编写的C++dll(native,而不是.net),我想使用VisualLisp的功能。任何人都可以指出如何执行此操作的示例,或者至少要阅读哪部分文档吗? 最佳答案 我通过为我的dll编写一个activex/COM包装器解决了这个问题,我认为这应该使将来更容易链接。在theswamp上开始一个线程从好人那里得到了一些关于如何从VisualLisp调用COM的答案。作为记录,它看起来像这样://inc++...(headerandIDLfilealsoneeded)hresulttimestwo(doublein,doubl

c++ - 将日期和时间数字转换为 time_t 并指定时区

我有以下整数:inty,mon,d,h,min,s;它们的值为:2012、06、27、12、47,53分别。如果我在我的应用程序中的其他地方选择了“UTC”,我想表示“2012/06/2712:47:53UTC”的日期时间,或者如果我选择了“2012/06/2712:47:53AEST”在我的应用程序的其他地方选择了“AEST”。我想将其转换为time_t,这是我目前使用的代码:structtmtimeinfo;timeinfo.tm_year=year-1900;timeinfo.tm_mon=mon-1;timeinfo.tm_mday=day;timeinfo.tm_hour=h

c++ - 如果在我执行 timed_wait 时系统时间发生变化怎么办?

当在具有持续时间的boost::condition_variable上使用timed_wait时,等待条件是否会在持续时间后超时,即使用户(或ntp)更改了系统时间?例如,boost::posix_time::time_durationwait_duration(0,0,1,0);//1sec//**Systemtimejumpsback15minuteshere.**if(!signal.timed_wait(lock,wait_duration)){//Doesthisconditionhappen1secondlater,orabout15minuteslater?}

c++ - 如何将分数纪元时间戳( double )转换为 std::chrono::time_point?

我有一个小数纪元时间戳,表示为double,我想将其转换为适当的std::chrono::time_point。纪元是自1/1/1970以来的常用UNIX纪元。我知道存在std::chrono::system_clock::from_time_t,但是time_t没有小数部分。使用C++11方法执行此操作的最佳方法是什么?这个问题与unixtimestamptoboost::posix_time::ptime有关,除了它要求的是C++11而不是它的Boost版本。 最佳答案 假设纪元与已知的时钟类型相同,您可以使用具有double表

c++ - gcc 和 clang 抛出 "no matching function call"但 msvc (cl) 编译并按预期工作

我写了一个小的函数模板,将不同的容器连接到一个新的容器中:#include#include#include#include#includenamespaceimpl{templatevoidjoin(OutIteratoriterator,constContainer&container,constContainers&...containers){for(constauto&item:container)*iterator++=item;join(iterator,containers...);//gccandclangcannotresolvethiscall}templatevo

c++ - 将 steady_clock::time_point 转换为 time_t

我正在使用steady_clock来保存一些消息的时间戳。出于调试目的,拥有日历(或类似的东西)很有用。对于其他时钟,有静态函数to_time_t,但在GCC(MinGW4.8.0)上,此函数不存在。现在我打印类似的东西:Timestamp:26735259098242对于时间戳,我需要一个steady_clock,所以我不能使用system_clock或其他。编辑之前的打印是从time_since_epoch().count()给出的 最佳答案 假设您需要内部计算的稳定行为,而不是显示,这里有一个函数可用于转换为time_t以供显

c++ - time() 返回的 time_t 是否特定于区域?

我刚接触并对time_t有疑问和time().我阅读了如下记录的函数time():time_ttime(time_t*timer);GetcurrenttimeGetthecurrentcalendartimeasatime_tobject.Thefunctionreturnsthisvalue,andiftheargumentisnotanullpointer,thevalueisalsosettotheobjectpointedbytimer.文档没有讨论时区。因此,对于以下C++代码:time_tt=time(NULL);如果两台机器,一台在美国,一台在英国,都执行函数调用tim

c++ - c++ : error: must use '.*' or '->*' to call pointer-to-member function in function 中的函数指针

代码片段如下。无法理解为什么会出现此错误。voidSipObj::check_each_field(){map::iteratormsg;stringstr;charname[20];boolres=false;sscanf(get_payload(),"%s%*s",name);LOGINFO(lc())second;res=(this).*sip_field();}}typedefbool(SipObj::*sip_field_getter)();staticmapsip_field_map;sip_field_getter是函数名的占位符 最佳答案

c++ - 尝试包装函数返回值时出现 "<class name> does not provide a call operator"错误

我正在尝试编写一个函数,它将一个仿函数作为参数,调用仿函数,然后返回它的返回值,并将其包装在boost::shared_ptr中。以下拒绝编译,我完全没有想法。我得到“std::vector不提供调用操作符”(大致)。我在MacOSX上使用Clang3.1。templateboost::shared_ptrReturnValueAsShared(boost::functionfunc){returnboost::make_shared(func());}这是我尝试使用它的上下文:make_shared>>>(bind(ReturnValueAsShared>,bind([afuncti