草庐IT

assignment_date

全部标签

c++ - 如何使用 boost Date_Time 获取以毫秒为单位的 GMT 时间?

有没有一种简单的方法可以从boostDate_Time库获取当前GMT时间(以毫秒为单位)?这是一个使用time_of_day的例子,我不想要time_of_day而是totaltimeinGMT作为longlongint:boost::posix_time::ptimetime=boost::posix_time::microsec_clock::universal_time();boost::posix_time::time_durationduration(time.time_of_day());//???longlonginttimeInMilliseconds=duratio

C++ 编程 : Assignment's Output is Marginally Off

好的,任务是从名为tickets.txt的文件中获取输入,并输出售出的门票总数以及总收入。文本文件中的值在两列中输入(1)售出的门票数量,以及(2)每个门票类别的价格。文本文件如下所示:25057501002800050357502518750这是我想出的代码...#include#include#includeusingnamespacestd;/*ProgramName:Ticket_Sales.cpp*Date:May2,2018*Purpose:CalculateTotalTicketSales*/intmain(){{ifstreaminFile;floatticket_co

c++ - QML:在 QML 中使用 cpp 信号总是导致 "Cannot assign to non-existent property"

我只是想将一个cpp信号连接到一个qml槽并尝试了不同的方法,但它总是在运行时导致相同的QML错误:无法分配给不存在的属性“onProcessed”!为什么?这是我的Cpp对象:#includeclassImageProcessor:publicQObject{Q_OBJECTpublic:explicitImageProcessor(QObject*parent=0);signals:voidProcessed(constQStringstr);publicslots:voidprocessImage(constQString&image);};ImageProcessor::Ima

c++ - 使用 boost date_time 解析和创建 HTTP 日期

我正在编写一种HTTP代理,所以我需要能够做3件事:根据RFC2616,sec3.3中指定的3种格式中的任何一种解析HTTP日期,将文件日期时间转换为HTTP日期字符串,并且将日期输出为字符串。作为引用,这些是我需要解析的日期时间示例。我将只输出第一种格式:Sun,06Nov199408:49:37GMT;RFC822,updatedbyRFC1123Sunday,06-Nov-9408:49:37GMT;RFC850,obsoletedbyRFC1036SunNov608:49:371994;ANSIC'sasctime()format我很确定Boostdate_time可以完成所有

C++ move 语义 : why copy assignment operator=(&) is called instead of move assignment operator=(&&)?

我有以下代码:#include#includeusingstd::cout;structSomeType{SomeType(){}SomeType(constSomeType&&other){cout我希望move构造函数调用move赋值运算符。下面是这个程序的输出:SomeType(SomeType&&)operator=(constSomeType&)operator=(SomeType&&)如您所见,move赋值运算符已成功调用,但在move构造函数内分配给*this时未成功调用。为什么会发生这种情况,我能以某种方式解决它吗? 最佳答案

c++ - 错误 :incompatible types in assignment of 'const char[5]' to 'char[10]'

我已经将c定义为charc[][10]在函数定义中并像c[i]="gray";一样使用它怎么了?我在网上搜索,它显示相同的语法。谢谢。 最佳答案 您不能对数组使用赋值(=)。如果将c更改为指针数组,这可能会起作用,具体取决于您需要使用它做什么。constchar*c[20];c[i]="gray";或者如果声明的类型必须是数组的数组,您可以使用strncpy:charc[20][10];strncpy(c[i],"gray",sizeof(c[i])); 关于c++-错误:incompa

c++ - 使用 boost::assign::list_of 构造 std::vector 时的歧义

这段代码:std::vector(boost::assign::list_of(1)(2)(3));给出错误:main.cpp:Inmemberfunction'void::RequestHandler::processRequest(Foo&,Bar,unsignedint,unsignedint*,constchar*,boost::shared_ptr&)':main.cpp:450:error:callofoverloaded'vector(boost::assign_detail::generic_list&)'isambiguous/4.4.2/bits/stl_vecto

c++ - std::vector::assign/std::vector::operator=(const&) 是否保证重用 `this` 中的缓冲区?

如果我将一个vector分配或复制到另一个vector(其容量与前者的大小相同或更大),我可以假设后者的缓冲区将被重用吗?下面的例子证明我可以,但是,标准保证吗?std::vector::assign和std::vector::operator=在这方面的行为有什么不同吗?#include#include#includeintmain(){std::vectora{1,2,3,4,5};std::vectorb{1,2,3,4};std::vectorc{1,2,3,4,5,6,7,8,9,10};std::coutLiveexample.更新:Thisanswer提到voidassi

c++ - is_assignable 和 std::unique_ptr

Here是来自gcc的测试文件,livedemostructdo_nothing{templatevoidoperator()(T*){}};intmain(){inti=0;std::unique_ptrp1(&i);std::unique_ptrp2;static_assert(!std::is_assignable::value,"");//note!here.}std::is_assignableIftheexpressionstd::declval()=std::declval()iswell-formedinunevaluatedcontext,providesthemem

c++ - boost::date_time, g++-4.7.0, 编译错误

以下代码在g++-4.7.0下出现编译错误,但在g++-4.6下编译正常。#include#includeusingnamespacestd;intmain(){boost::posix_time::ptimetime_t_epoch(boost::gregorian::date(1970,1,1));cout下面是反复看到的错误信息(编译器输出了很多信息)/usr/include/boost/date_time/local_time/local_date_time.hpp:433:84:error:useofdeletedfunctionboost::shared_ptr>::sha