草庐IT

string-comparison-functions

全部标签

c++ - 在没有 std::string 的情况下构造字符串

我正在做一个不允许我们使用的项目完全没有库——我们只能使用字符串作为字符指针,我们必须为它们编写自己的函数(strcpy、strlen等)。我正在尝试使用以下头文件构建RentalCar类:#ifndefRENTALCAR_H#defineRENTALCAR_HclassRentalCar{public:RentalCar();RentalCar(char*make,char*model);char*getMake()const;char*getModel()const;voidsetMake(char*make="");voidsetModel(char*model="");priv

c++ - 基类中的唯一指针禁止实例化,错误为 "attempting to reference a deleted function"

我将我的C++工具链从VisualStudio2013更新到VisualStudio2017/2019。现在我遇到了一些形式的编译错误:(13):errorC2280:'OfflineFixture::OfflineFixture(constOfflineFixture&)':attemptingtoreferenceadeletedfunction(8):note:compilerhasgenerated'OfflineFixture::OfflineFixture'here(8):note:'OfflineFixture::OfflineFixture(constOfflineFi

c++ - std::basic_string 的使用

basic_string类显然被设计为通用容器,因为除了c_str()函数外,我在其规范中找不到任何特定于文本的函数。出于好奇,除了存储人类可读的字符数据之外,您是否曾将std::basic_string容器类用于其他用途?我问这个问题的原因是,人们常常不得不在通用或具体之间做出选择。设计者选择将std::basic_string类设为通用类,但我怀疑它是否曾经以这种方式使用过。 最佳答案 它被设计为一个字符串类(因此,例如length()和所有那些查找函数),但是在将STL引入标准库之后,它也被装备为一个STL容器(因此size(

标准库中的string类(下)——“C++”

各位CSDN的uu们你们好呀,这段时间小雅兰的内容仍然是C++string类的使用的内容,下面,让我们进入string类的世界吧!!! string类的常用接口说明string-C++Referencestring类的常用接口说明string类对象的修改操作 insert这是在第五个位置插入xxxx这个字符串!下面的代码的意思是头插4个x字符! 头插还可以这么写,用迭代器的方式!#include#includeusingnamespacestd;intmain(){ strings1("helloworld"); s1.insert(5,"xxxx"); coutinsert最常见的用法还是插

c++ - std::tr1::function 是否有合理的默认值?

我花了一些时间在谷歌上搜索,但没有真正找到任何东西。我希望能够做到这一点:std::tr1::functionfoo(SOME_DEFAULT_FUNCTION_THAT_DOES_NOTHING);////Somecodethatcouldpossiblyassignfoo//foo();否则我必须这样做:std::tr1::functionfoo;////Somecodethatcouldpossiblyassignfoo//if(foo){foo();}我意识到我可以创建一个什么都不做的函数,但我正在寻找一些标准的方法来不必处理检查函数是否被赋予空对象模式的值。

C++0x:std::function::target 和模板参数出错

我目前使用C++0x编写事件处理程序系统。每个事件的“处理程序”(可以有多个处理程序)通过传递可以存储在std::function中的任何类型的函数/方法来注册。目的。这是使用重载的+=运算符以C#风格完成的。我的事件类看起来基本上是这样的(为了更好的可读性而被剥离):templateclassEvent{public:typedefTHandlerReturn(HandlerSignature)(THandlerArgs...);typedefTHandlerReturn(*HandlerFuntionPtr)(THandlerArgs...);typedeftypenamestd:

c++ - 从 std::function 创建一个 boost::python::object

如何从std::function构建boost::python::object? 最佳答案 Useboost::python::make_function,并提供签名,因为默认签名不处理std::function。例如,我们要包装返回类型:std::functionget_string_function(conststd::string&name){return[=](intx,inty){returnname+"(x="+std::to_string(x)+",y="+std::to_string(y)+")";};}我们可以定义

c++ - 使用 int 和 string boost::interprocess 映射

我有以下代码使用boost进程间将映射保存到共享内存中usingnamespaceboost::interprocess;//Sharedmemoryfront-endthatisabletoconstructobjects//associatedwithac-string.Eraseprevioussharedmemorywiththename//tobeusedandcreatethememorysegmentatthespecifiedaddressandinitializeresourcesshared_memory_object::remove("MySharedMemory

c++ - xutility.h 错误 C2064 : term does not evaluate to a function taking 2 arguments

我有问题要问。我创建了一个名为AstarPlanlama的类并具有以下2个函数:boolAstarPlanlama::nodeComp(constNode*lhs,constNode*rhs){returnlhs->FF;}voidAstarPlanlama::enKucukFliNodeBul(std::list*OPEN){std::list::iteratorit=std::min_element(OPEN->begin(),OPEN->end(),&AstarPlanlama::nodeComp);OPEN->sort(&AstarPlanlama::nodeComp);Q=O

c++ - 从 GCC 得到 "no matching function"

为什么这个简单的代码不起作用?templateclassretype{typedefUtype;};classobject{public:templateintcreate(typenameretype::typep){return4;}};intmain(){intn=object().create(5);return0;}使用GCC编译时出现此错误:test.cpp:Infunction‘intmain()’:test.cpp:20:error:nomatchingfunctionforcallto‘object::create(int)’问题出在哪里?