草庐IT

package-scoped

全部标签

c++ - "Nested"scoped_lock

我缩短的简化类如下所示:classA{public://...methodA();methodB();protected:mutableboost::mutexm_mutex;sometype*m_myVar;}A::methodA(intsomeParam){boost::mutex::scoped_lockmyLock(m_mutex);m_myVar->doSomethingElse();}A::methodB(intsomeParam){boost::mutex::scoped_lockmyLock(m_mutex);m_myVar->doSomething();this->m

c++ - 如何使用 std::scoped_allocator_adapter?

据我了解,std::scoped_allocator_adapter提供一种控制机制,用于指定单独哪个分配器将由容器、其元素、其元素的元素等使用,假设元素本身是容器。也就是说,我无法理解std::scoped_allocator_adapter的语义.BjarneStroustrup在TheC++ProgrammingLanguage,section34.4.4,pg中提供了以下4个示例。1001(在接下来的问题中,我将它们称为Example-1、Example-2等。):Wehavefouralternativesforallocationofvectorsofstrings://v

C++ block scope extern declaration linkage,混淆C++标准解释

标准N3242(C++11草案)和N3797(C++14draft)两者有相同的段落。§3.5Programandlinkage[basic.link]¶6Thenameofafunctiondeclaredinblockscopeandthenameofavariabledeclaredbyablockscopeexterndeclarationhavelinkage.Ifthereisavisibledeclarationofanentitywithlinkagehavingthesamenameandtype,ignoringentitiesdeclaredoutsidethei

c++ - 错误 : uint64_t was not declared in this scope when compiling C++ program

我正在尝试一个简单的程序来打印steady_clock的时间戳值,如下所示:#include#includeusingnamespacestd;intmain(){cout(steady_clock::now().time_since_epoch()).count();cout但是每当我像这样编译时g++-oabcabc.cpp,我总是会遇到错误:Infileincludedfrom/usr/include/c++/4.6/chrono:35:0,fromabc.cpp:2:/usr/include/c++/4.6/bits/c++0x_warning.h:32:2:error:#er

c++ - 非本地 lambda 和捕获变量 - "block scope"是什么意思

我目前正在玩c++11lambda,发现了一个我无法理解的例子。根据标准:Alambda-expressionwhosesmallestenclosingscopeisablockscope(3.3.3)isalocallambdaexpression;anyotherlambda-expressionshallnothaveacapture-listinitslambda-introducer所以,我创建了一个简单的例子:inta=10;autox=[a]{return1;};intmain(){intk=5;autop=[k]{returnk;};return0;}ideone中的

c++ - 为什么需要 Visual C++ Redistributable Package?

如果visualC++编译器编译的代码是纯C++,为什么还需要可再分发的包?这会使您的代码依赖于平台吗?将可视化C++编译器与可再发行组件包一起使用是否比将其他IDE与g++一起使用有任何优势? 最佳答案 代码不依赖于平台,生成的可执行文件是。它与带有标准库实现的MS库链接,这些库作为DLL包含在可再分发文件中。IIRC应该有一个静态链接所有内容的选项,这样您就不需要额外的可再发行组件,但生成的二进制文件仍将依赖于平台——例如,您不能在UNIX系统上运行Windows二进制文件(至少没有WINE)。

c++ - 如何创建带参数的 packaged_task?

正在关注thisexcellenttutorial对于futures、promises和打包任务,我到了要准备自己的任务的地步#include#includeusingnamespacestd;intackermann(intm,intn){//mighttakeawhileif(m==0)returnn+1;if(n==0)returnackermann(m-1,1);returnackermann(m-1,ackermann(m,n-1));}intmain(){packaged_tasktask1{&ackermann,3,11};//就我能破译gcc-4.7.0错误消息而言,它

C++:为什么这个简单的 Scope Guard 有效?

到目前为止,每个看过的作用域守卫都有一个守卫bool变量。例如,请参阅此讨论:Thesimplestandneatestc++11ScopeGuard但是一个简单的守卫可以工作(gcc4.9,clang3.6.0):templatestructfinally_t:publicC{finally_t(C&&c):C(c){}~finally_t(){(*this)();}};templatestaticfinally_tfinally_create(C&&c){returnstd::forward(c);}#defineFINCAT_(a,b)a##b#defineFINCAT(a,b)

c++ - C++ 11 中 boost::scoped_ptr 的替代方案

我们刚刚将编译器升级到支持C++11的VC++2013。之前我们一直在使用来自Boost的shared_ptr和scoped_ptr类,但由于这是我们一直在使用的Boost类,我们正在寻找删除该依赖项。据我所知,std::shared_ptrs是boost::shared_ptrs的直接替代品,所以这(希望)很容易。但是,Boostscoped_ptrs的最佳替代品是什么(如果有的话)?会是unique_ptr吗?(老实说,虽然我写了代码,但那是大约10年前的事了,我已经忘记了使用scoped_ptrs的目的是什么......也许我只是在“玩”Boost,但到目前为止正如我所看到的,在

c++ - 使用 std::packaged_task 时 std::future 仍然延迟(VS11)

看来除非你调用std::async一个std::future绝不会设置为除future_status::deferred以外的任何其他状态除非你调用get或wait关于future。wait_for&wait_until将继续不阻塞并返回future_status::deferred即使任务已经运行并存储了结果。这是一个例子:#includevoidmain(){autofunc=[](){return5;};autoasyncFuture=std::async(std::launch::async,func);autostatus=asyncFuture.wait_for(std::