草庐IT

name-binding

全部标签

c++ - 确保 std::bind 提供正确数量的参数

更改std::function的签名后,我想知道编译器没有提示我还没有更改的函数签名。基本上,我的代码如下所示:#include#include#includeclassCallbackCaller{public:typedefstd::functionCallbackFunction;voidregisterCallbackFunction(CallbackFunctioncb_function){callback_functions_.push_back(cb_function);}voidcallThemAll(){for(CallbackFunction&cb_function

c++ - std::bind 可变参数模板和自动返回类型

遵循thisquestion中的代码,我有一个带有可变参数模板函数的std::bind。如果我尝试提供带有auto返回值的函数模​​板,gcc会拒绝该程序:#includetemplateautoinv(Args...args){autobound=std::bind(&inv_impl,args...);returnbound;}intmain(){autob=inv(1,2);}编译错误为:foo.cc:Ininstantiationof‘autoinv(Args...)[withArgs={int,int}]’:foo.cc:41:30:requiredfromherefoo.c

【LaTeX 问题解决方案】I couldn‘t open file name `.aux‘

最近用vscode的latex插件编译论文的时候发现,编译bibtex时总会报错:Icouldn’topenfilename“.aux”。但是在编译xelatex时发现已经产生了一个aux文件,那么为什么latex插件无法找到aux文件呢?经过一番摸索,我发现问题出现在设置文件中。"latex-workshop.latex.clean.fileTypes":[//"*.aux","*.bbl","*.blg","*.idx","*.ind","*.lof","*.lot","*.out","*.toc","*.acn","*.acr","*.alg","*.glg","*.glo","*.gl

c++ - 通过 boost::bind 从 vector 中删除字符串

我正在尝试从vector中删除短字符串。std::vectorvec;//...vec.erase(std::remove_if(vec.begin(),vec.end(),boost::bind(std::less(),boost::bind(&std::string::length,_1),5),vec.end());编译器吐出一条非常大的错误信息:qwer.cpp:20:error:nomatchingfunctionforcallto'remove_if(__gnu_cxx::__normal_iterator,std::allocator>*,std::vector,std:

c++ - boost 绑定(bind)一个引用的函数

我在编译以下片段时遇到问题inttemp;vectororigins;vectororiginTokens=OTUtils::tokenize(buffer,",");//bufferisachar[]array//originalloopBOOST_FOREACH(strings,originTokens){from_string(temp,s);origins.push_back(temp);}//I'dliketousethistoreplacetheaboveloopstd::transform(originTokens.begin(),originTokens.end(),o

c++ - 模板 :Name resolution:Point of instantiation: -->can any one tell some more examples for this statement?

这是来自ISOC++标准14.6.4.1实例化点的声明Forafunctiontemplatespecialization,amemberfunctiontemplatespecialization,oraspecializationforamemberfunctionorstaticdatamemberofaclasstemplate,ifthespecializationisimplicitlyinstantiatedbecauseitisreferencedfromwithinanothertemplatespecializationandthecontextfromwhichi

c++ - Boost 函数:存储 boost::bind 返回的任何函数?

我想编写一个异步计时器,在经过一定时间后调用一个函数。现在我希望能够使用boost::bind()将函数与定时器在特定时间间隔过去后调用的任何签名绑定(bind)。我现在的做法是受到boostthread的启发,它有一个抽象基类来存储线程函数。这就是我所做的:classTimedFunctionBase{public:virtualvoidcall()=0;};typedefstd::shared_ptrTimedFunctionBasePtr;templateclassTimedFunction:publicTimedFunctionBase{public:TimedFunction

c++ - 使用嵌套的 boost::binds

Compiler:g++4.4.3Boost...:1.49.0OS......:UbuntuNote:It'sbeen15yearssinceIseriouslyusedC++,soI'mrelearningandlearningnewthingsasIalsotrytolearnBoost.Giventhefollowingcode:1.classBeta{2.public:3.std::stringname();4.}5.6.classAlpha{7.public:8.Betam_beta;9.}10.11.Alphaone;因为各种原因,想用boost:bind来实现与调用“o

c++ - g++ std::bind 错误与 shared_ptr

我无法理解为什么以下代码无法编译。#include#includeclassFoo{public:voidBar(inti){}};voidX(std::function)>f){}intmain(){std::shared_ptrf(newFoo);autof1(std::bind(&Foo::Bar,std::placeholders::_1,1));X(f1);return0;}g++(4.6.3)输出...nfileincludedfrom/usr/include/c++/4.6/memory:80:0,fromtest.cpp:1:/usr/include/c++/4.6/f

c++ - C++ 错误 : a expected initializer before [function name]

这个问题不太可能帮助任何future的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visitthehelpcenter.关闭9年前。我正在用C++刷新self(自从上学后就没用过),我写了一个简单的程序来凑热闹。我的问题是当我编译它窒息的程序时说“错误:'stringThing'之前的预期初始化程序”这样做是有原因的吗?我知道这可能是一个菜鸟问题,所以我检查了stackoverflow,但找不到任何相关问题可以给我答案。*我正在使用GNUGCC编译器代码:#includeusingna