草庐IT

mutable-context-wrapper

全部标签

c++ - 为 std::reference_wrapper 赋值

我们如何为std::reference_wrapper包装的项目赋值?inta[]={0,1,2,3,4};std::vector>v(a,a+5);v[0]=1234;//Error,cannotassignvalue!根据错误,删除了直接赋值:error:useofdeletedfunction'std::reference_wrapper::reference_wrapper(_Tp&&)[with_Tp=int]' 最佳答案 使用get()成员函数:v[0].get()=1111;//okHere是std::referenc

c++ - 什么是 "allocation context"?

我是一名学生,我必须进行有关内存泄漏检测的研究。在许多论文中,他们都在谈论分配背景。我不知道这是什么意思。我找不到任何allocationcontext的定义(或翻译,我来自德国)。举个例子,引用一篇论文(DetectingMemoryLeaksthroughIntrospectiveDynamic使用机器学习的行为建模):Thekeyideabehindusingmachinelearningisthataleakingobjectisdiscerniblebyobservingthelifetimesofothersimilarobjects.Thatis,anobjectcanb

c++ - boost::asio::yield_context:意外的 forced_unwind 异常

我正在尝试为boost::asio编写自定义异步函数,如here所述.但是我在result.get上遇到了boost::coroutines::detail::forced_unwind异常#include#include#include#include#includenamespaceasio=::boost::asio;templateautomy_timer(Timer&timer,Token&&token){typenameasio::handler_type::typehandler(std::forward(token));asio::async_resultresult(

c++ - Boost 库中的 Io_context 错误

我正在尝试使用BoostLibraries构建聊天室。但是当我尝试使用asio::io_context时,编译器说:io_contextisnotanmemberofasio.我构建了4次Boost,我认为问题可能是由于我的安装失败造成的,但事实并非如此。#include#include#include#include#include#include#includeusingboost::asio::ip::tcp;std::stringmake_daytime_string(){usingnamespacestd;//Fortime_t,timeandctime;time_tnow=

c++ - 使用 std::reference_wrapper 作为 std::map 中的键

我在类层次结构中有一堆对象,我想制作一个std::map使用对这些对象的引用作为映射中的键。它看起来像std::reference_wrapper正是为此所需要的,但我似乎无法让它发挥作用。到目前为止我尝试了什么:classObject{//baseclassofmyhierarchy//mostdetailsunimportantpublicvirtualbooloperator,int>table;autoit=table.find(object);table[object]=42;table[object]++但是,我总是从编译器中得到一些模糊的错误:/usr/include/c

c++ - 运行 SonarQube 分析扫描 - SonarSource build-wrapper

我是运行SonarQube扫描的新手,我在Jenkins的日志中收到此错误消息:16:17:3916:17:36.926ERROR-TheonlywaytogetanaccurateanalysisofyourC/C++/Objective-CprojectisbyusingtheSonarSourcebuild-wrapper.Ifforanyreason,theuseofthebuild-wrapperisnotpossibleonyourproject,youcanbypassitwiththehelpofthe"sonar.cfamily.build-wrapper-outpu

c++ - 'default-initialization in copy-initialization context' 在 C++ 中是什么意思?

例如,我想我理解直接初始化(与复制)上下文中的列表初始化意味着什么-intx{}与intx={}基本上。但是在cppreference我发现了这个:Whenanobjectofclasstypeiscopy-initializedfromanobjectofthesameorderivedclasstype,ordefault-initializedinacopy-initializationcontext,thecandidatefunctionsareallconvertingconstructorsoftheclassbeinginitialized.Theargumentlis

c++ - std::reference_wrapper<T> 在容器中的使用

如果可以的话,我会从我的代码中删除所有原始指针*,因为使用它们可能不是线程安全的,而且设计意图不明确(可选值、所有权等)。然而,有时候不使用指针并不是那么容易。例如,我们倾向于在多态类型的容器中使用指向基类型的指针:classA:noncopyable{...};classB:publicA{...};std::vectorv;v.emplace_back(newB);//temporarycontainerforsomeoperationstd::vectorselected;if(check())selected.emplace_back(v.front());你对上面的代码有什么

c++ - 我可以实例化一个 std::reference_wrapper<T> 吗,其中 T 是一个不完整的类型?

是否std::reference_wrapper允许T不完整,与T&相同可以不用T处理完成了吗?GCC4.9接受以下内容:#includestructwoof;structtest{test(woof&w):w(w){}std::reference_wrapperw;};structwoof{inta;};intmain(){woofw;testt=w;//(braced-initwouldbebetter,butVS2012!)}但MSVS2012拒绝它并显示以下消息:Error1errorC2139:'woof':anundefinedclassisnotallowedasanar

c# - 为 Windows 编写我自己的自定义命令行 "wrapper"

我从来都不是Windows命令行的粉丝。我尝试过powercmd之类的工具并喜欢它们,但大多数都不是免费分发的,而且我不喜欢为我认为可以自己编写的东西付费的想法。我想编写自己的命令行包装器,类似于允许这些属性的powercmd:自定义字体和颜色窗口的不透明度在一个面板中同时打开多个窗口(可能类似于标签式浏览)能够调整窗口大小我现在正在与你们联系,帮助我决定是应该在VisualStudio中使用C#尝试这个,还是应该在Java中使用Swing来尝试这个。我对两者都很满意。有没有人做过这样的命令行包装器?如果是,您使用的是什么语言?您的经验是什么?感谢您的任何反馈。授予-