草庐IT

point_normal

全部标签

c++ - 在 "test mode"中打印信息,但不在 "normal execution"中打印信息

我正在使用c++中的应用程序,它使用特殊的dprintf函数来打印信息,这是一个示例:dprintf(verbose,"Thevalueis:%d",i);我正在做的是,当我出于测试目的定义冗长然后打印信息时,当我在正常执行中工作时我没有定义它并且我没有在屏幕上看到无用的信息。我的问题是如何执行该功能或实现相同的想法? 最佳答案 我尽量避免使用var-argC风格的函数,主要原因有两个:它们不是类型安全的,不能使用运算符他们无法识别何时提供的论点太少或太多我创建了一种使用boost::fusion的方法,它以类型安全的方式提供参数。

c++ - boost::filesystem::path::lexically_normal: 这是不正确的行为吗?

boost::filesystem::path::lexically_normal()的文档指出:Returns*thiswithredundantcurrentdirectory(dot),parentdirectory(dot-dot),anddirectory-separatorelementsremoved.参见:http://www.boost.org/doc/libs/1_63_0/libs/filesystem/doc/reference.html.以下打印./test(使用Boost1.63.0),我希望test:#include#includeintmain(void

c++ - Q : Template class that takes either a normal type or a template template argument

最近我设计了元类型和允许编译时类型连接的可能操作:#includetemplatetypenameT>structMetaTypeTag{};/*variabletemplatehelper*/templatetypenameT>constexprMetaTypeTagmeta_type_tag={};templatestructTypeTag{};/*comparison*/templateconstexprbooloperator==(TypeTag,TypeTag){returntrue;}templateconstexprbooloperator==(TypeTag,TypeT

c++ - std::string 到 std::chrono time_point

我有以下时间格式的字符串:“%Y-%m-%d%H:%M:%S.%f”其中%f是毫秒,例如:14:31:23.946571我想把它作为chronotime_point。有Actor阵容吗? 最佳答案 std::string没有转换至std::chrono::time_point.你必须建立std::chrono::time_point对象。使用除微秒以外的所有内容来构造std::tm对象()。年份应基于1900,而不是0。月份应基于0,而不是1。使用std::mktime()创建一个std::time_t目的。创建std::chron

c++ - SSE 和 iostream : wrong output for floating point types

测试.cpp:#includeusingnamespacestd;intmain(){doublepi=3.14;cout当使用g++-mno-ssetest.cpp在cygwin64位上编译时,输出为:pi:0但是,如果使用g++test.cpp编译,它可以正常工作。.我有GCC版本5.4.0。 最佳答案 是的,我复制了这个。嗯,主要是。我实际上没有得到0的输出,而是一些其他的垃圾输出。所以我可以重现无效的行为,并且我已经查明了原因。您可以看到GCC5.4.0使用-m64-mno-sse标志hereonGoldbolt'sComp

c++ - 删除指向不完整类型的指针 'Point' ;没有调用析构函数

我有2个文件:Point.h:classPoint{intx;inty;char*name;public:Point(){name=newchar[5];}~Point(){delete[]name;}};和:Line.h:classPoint;classLine{Point*p;public:Line(){p=newPoint[2];.......}~Line(){delete[]p;}};但是当我编译时,我得到了下一个错误:deletionofpointertoincompletetype'Point';nodestructorcalled感谢任何帮助!

c++ - 对象成员的迭代器 "pointing"

我承认我很难对此做出合理的描述。我想不出一个好词来准确描述我正在寻找的东西。也许这可以称为切片迭代器。假设我有这样的东西:structS{inti;char*s;floatf;};std::vectorv(10);我正在寻找一种构造迭代器的方法,它将指向S的成员。我希望能够将它传递给std::min_element之类的东西,而无需在每种情况下都创建谓词。可能看起来像这样的东西:std::min_element(slicing_iterator(v.begin(),S::f),slicing_iterator(v.end(),S::f));我可以使用任何模板技巧来实现这一目标吗?或者它

c++ - std::chrono:将自定义持续时间添加到 time_point

以下代码可以编译(g++4.7.2):#includetypedefstd::chrono::durationdouble_prec_seconds;typedefstd::chrono::time_pointtimepoint_t;voiddo_something(consttimepoint_t&tm){//...}intmain(intargc,char**argv){timepoint_tt0=std::chrono::system_clock::now();timepoint_tt1=t0+std::chrono::seconds(3);//timepoint_tt3=t0+

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++ - 将 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以供显