草庐IT

mysqli_stmt_bind_param

全部标签

c++ - std::bind std::shared_ptr 参数不会增加 use_count

以下代码:#include#include#includestructFoo{Foo():m_p(std::make_shared()){}Foo(constFoo&foo){printf("copy\n");}std::shared_ptrm_p;};voidfunc(Foofoo){}intmain(){Foofoo;std::functionf=std::bind(func,foo);printf("usecount:%ld\n",foo.m_p.use_count());f();}得到结果:copycopyusecount:1copy由于复制了Foo,所以我认为m_p的use_

c++ - 如何将 std::bind 对象传递给函数

我需要将一个绑定(bind)函数传递给另一个函数,但我收到错误提示没有可用的转换-cannotconvertargument2from'std::_Bind&>'to'std::function&'函数:std::stringkeyFormatter(std::stringsKeyFormat,std::stringskey){boost::replace_all(sKeyFormat,"$ID$",skey);returnsKeyFormat;}用法就像-autofun=std::bind(&keyFormatter,sKeyFormat,std::placeholders::_2)

c++ - 将 std::bind 与重载函数一起使用

我无法找到如何使用std::bind将参数绑定(bind)到重载函数。std::bind无法推断出重载类型(对于其模板参数)。如果我不重载函数,一切正常。代码如下:#include#include#includeusingnamespacestd;usingnamespacestd::placeholders;doublef(doublex){returnx;}//std::bindworksifthisoverloadediscommentedoutfloatf(floatx){returnx;}//wanttobindto`f(2)`,forthedouble(double)ver

c++ - 将 boost::bind 与构造函数一起使用

我正在尝试创建新对象并将它们添加到使用boost::bind的对象列表中。例如。structStuff{intsome_member;};structObject{Object(intn);};....lista;listobjs;....transform(a.begin(),a.end(),back_inserter(objs),boost::bind(Object,boost::bind(&Stuff::some_member,_1)));这似乎不起作用。有什么方法可以使用带有boost::bind的构造函数,还是我应该尝试其他方法? 最佳答案

c++ - 指向绑定(bind)函数的指针只能用于调用该函数

我正在为我的C++类(class)布置家庭作业,遇到了一个问题,我无法弄清楚我做错了什么。请注意,文件的分离是必要的,我意识到如果我只是在main中创建一个结构AttackStyles并放弃额外的,这会容易得多类文件。我的问题的根源在于我似乎无法遍历类数组并提取基础数据。这是代码://AttackStyles.h#ifndefATTACKSTYLES_H#defineATTACKSTYLES_H#include#includeusingnamespacestd;classAttackStyles{private:intstyleId;stringstyleName;public://C

c++ - std::bind 和 winsock.h 绑定(bind)混淆

我正在处理一个非常大的项目,在一个文件中我们突然遇到编译时错误,编译器似乎认为我们对winsock.hbind()的调用实际上是对std::bind()的调用。似乎在包含文件中的某处有usingnamespacestd代码片段。我们可以尝试找到这些usingnamespacestd在哪里被使用并删除它们,但也许有更好的方法来做到这一点? 最佳答案 您可以更改您的调用以使用::bind()来指定全局命名空间。 关于c++-std::bind和winsock.h绑定(bind)混淆,我们在S

c++ - 为什么我不能将 const 左值引用绑定(bind)到返回 T&& 的函数?

我将一个函数的一些返回值绑定(bind)到一个const左值引用,但是在const左值引用的生命周期结束之前,该对象被删除了。在下面的示例中,Foo对象在foo的生命周期结束之前被销毁:#include#includestructFoo{~Foo(){std::cout输出是:Foodestroyed:somestringbeforescopeend在coliru上直播:1我认为您可以将constT&绑定(bind)到任何东西。返回T&&是不好的做法吗?应该首选按值返回吗?我在这里的cpprestsdk中偶然发现了这个:inlineutility::string_t&&to_strin

c++ - 是否有带有 C++ 语言绑定(bind)的图形数据库?

我什至很难找到一个。我们中的一些人仍在使用C++进行编码...开源跨平台会很好。 最佳答案 OrientDB应该允许C++。基于此link上的文档-"CLanguagebinding兼容C++和其他支持C调用的语言"许可是Apache2.0。因此,除非您需要他们额外的专业支持,否则您无需支付任何费用。它也适用于蓝图。 关于c++-是否有带有C++语言绑定(bind)的图形数据库?,我们在StackOverflow上找到一个类似的问题: https://stac

c++ - 包装右值引用 lambda 时 std::async 和 std::bind 之间的区别

受此启发comment关于将带有右值引用参数的lambda直接绑定(bind)到std::async,通过std::async将右值绑定(bind)到lambda编译并按预期执行:(liveexample)autolambda=[](std::string&&message){std::cout但是,使用std::bind会触发编译器错误:(liveexample)autolambda=[](std::string&&message){std::cout这是因为std::bind将message保留为左值,因此当它传递给lambda时,参数不再与参数匹配。我已经readstd::asy

c++ - 通过不明确的转换运算符进行引用绑定(bind)

#includeusingnamespacestd;structCL2{CL2(){}CL2(constCL2&){}};CL2cl2;structCL1{CL1(){}operatorCL2&(){coutclang和gcc都给出了模糊的转换运算符,但VisualStudio编译正常并打印“operatorconstCL2&”。怎样才符合标准?据我所知,将CL1转换为constCL2&是在复制初始化上下文中(作为cl2对象直接初始化的一部分)。我看过n4296草稿,[over.match.copy]:Assumingthat“cv1T”isthetypeoftheobjectbein