草庐IT

In-memory

全部标签

c++ - 冒号 : used in variable initialization?

这个问题在这里已经有了答案:Whatdoesacoloninastructdeclarationmean,suchas:1,:7,:16,or:32?(3个答案)关闭7年前。我找到这条线here:uint32bIsHungry:1;...而且我从未见过这种用于初始化变量的语法。我已经习惯看到这个了:uint32bIsHungry=1;它看起来有点像一个初始化列表,但是对于单个字段?它是什么,它有什么作用,我为什么要关心?

c++ - 线程: Termination of infinite loop thread in c++

我试图编写一个线程,该线程将在我的主程序的后台运行并监视某事。在某个时候,主程序应该向线程发出信号以使其安全退出。这是一个最小示例,该示例以固定的时间间隔将本地时间写入命令行。#include#include#include#include#includeintfunc(bool&on){while(on){autot=std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());std::coutfi=std::async(std::launch::async,func,on);std::this_thr

c++ - 通过 https 发布时出现 "CURLE_OUT_OF_MEMORY"错误

我正在尝试编写一个使用libCurl将soap请求发布到安全Web服务的应用程序。此Windows应用程序是针对libCurl版本7.19.0构建的,而后者又是针对openssl-0.9.8i构建的。相关的curl相关代码如下:FILE*input_file=fopen(current->post_file_name.c_str(),"rb");FILE*output_file=fopen(current->results_file_name.c_str(),"wb");if(input_file&&output_file){structcurl_slist*header_opts=0

c++ - STL 模板容器的 GDB 中的 "Cannot evaluate function -- may be in-lined"错误

我希望能够使用GDB从STL容器中获取地址并打印一对。例如,给定以下玩具程序:#includeintmain(){std::mapamap;amap.insert(std::make_pair(1,2));}我编译为:g++-ggdb3-O0-std=c++11-Wall-Wextra-pedantic-omain.outmain.cpp然后,当我尝试检查map的单个元素时,例如:pamap.begin()我得到:"Cannotevaluatefunction--maybein-lined"为什么会发生这种情况,我该如何解决?在Ubuntu20.04、GCC9.3.0、2.34中测试。

c++ - 如何测试 std::memory_order_relaxed 的行为?

我已经阅读了std::memory_order_relaxed的文档.Relaxedordering的部分解释是......//Thread1:r1=y.load(memory_order_relaxed);//Ax.store(r1,memory_order_relaxed);//B//Thread2:r2=x.load(memory_order_relaxed);//Cy.store(42,memory_order_relaxed);//D对此的解释是……[It]isallowedtoproducer1==r2==42.Inparticular,thismayoccurifDisc

C++ 错误 : ‘_mm_sin_ps’ was not declared in this scope

我正在尝试对将函数应用于数组的不同方法进行基准测试。为什么是https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=3260,2124,4779,4779&cats=Trigonometry&text=_sin_mm_sin_ps在我的范围内未知,但_mm_sqrt_ps是?我如何让它为人所知?并编译无误。#include#include#include#include#include#include#include"immintrin.h"#includeintmain(){std::coutdis(-

C++分布式编程

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。关闭3年前。Improvethisquestion是否有用于分布式内存缓存、分布式任务、发布/订阅消息传递的库?我在Java中使用过Hazelcast,我想要类似的东西。我知道Memcached是一个内存缓存,甚至是分布式的,但它缺少消息传递和远程任务。我只需要一些东西来协调服务器集群,而无需使用传统的RPC和套接字编程。

C++ 标准 : default "const T& value" in vector constructor for type 'int'

explicitvector(size_typen,constT&value=T(),constAllocator&=Allocator());vectorvec(10);cout::const_iteratoriter=vec.begin();iter!=vec.end();++iter){coutVS2010的输出:vec.size:100000000000问题>:根据最新的C++标准,当我们使用vectorObject(size_type)定义一个vector对象时,默认的int值是多少?在这里你可以看到,VS2010输出0作为默认的int值。但我不知道这是否是C++标准所要求的

c++ - vector in struct 耗时吗?使用指针更好吗?

我在C++中有一个这样的结构:structMyStruct{someTypev1;someType2v2;someType3v3;someType4f1();std::vectormyVector;};它会经常以这样的形式使用://someprocess...afterwhichastd::vectorvec1isgeneratedMyStructmyStruct;myStruct.myVector=vec1;由于vec1比较大。我想知道通过执行分配myStruct.myVector=vec1;是否花费很多时间我是否应该在MyStruct中使用指向myVector的指针来使其更快?如何

c++ - 变长数组 : How to create a buffer with variable size in C++

我目前正在编写一个移动平均线类。目标是在创建Running_Average类的新对象时能够将缓冲区大小指定为构造函数的一部分。#include#include"Complex.h"#include#include#include#includeusingnamespacestd;classRunning_Average{public:doublesum=0;doubleaverage=0;inti;doubleAverage(void);//MemberfunctionsdeclarationvoidAddSample(double);Running_Average(int);};Ru