草庐IT

THIS_FILE

全部标签

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++ - 具有固定实现的虚函数不使用 (*this) 的大多数派生类

假设我有以下代码:structZ;structA{virtualvoidDo(Z&z)const;};structB:publicA{};structZ{voiduse(Aconst&a){}voiduse(Bconst&b){}};voidA::Do(Z&z)const{z.use(*this);}现在,当我调用B.do,this的类型是A,这是有道理的,因为do的实现在A中定义.有什么方法可以调用B.do使用use(Bconst&)无需为do复制粘贴相同的代码来自A进入B?在我的实际代码中,我有大约15个(并且还在不断增加)派生自某个基类的类,必须为do复制粘贴相同的代码似乎很浪费

c++ - 在基类中调用 shared_from_this() 时的 bad_weak_ptr

我有一个SuperParent类,一个Parent类(派生自SuperParent)并且都包含一个shared_ptr到一个Child类(它包含一个weak_ptr到一个SuperParent)。不幸的是,我在尝试设置Child的指针时遇到了bad_weak_ptr异常。代码如下:#include#include#include#includeusingnamespaceboost;classSuperParent;classChild{public:voidSetParent(shared_ptrparent){parent_=parent;}private:weak_ptrpare

Unity学习笔记--File.ReadAllLines和File.ReadAllText的使用以及注意事项(一定要看到最后!!!)

目录前言一、File.ReadAllLines参数返回例子二、File.ReadAllText参数返回例子注意事项可能出现的问题总结前言最近在做文件存储以及读取的时候,需要用到C#给我们提供的类:File具体使用方法可以看官方文档:C#File类这篇文章只会说File.ReadAllLines和File.ReadAllText的使用以及注意事项Tips:(一定要看到最后!!!)一、File.ReadAllLines重载操作ReadAllLines(String)打开一个文本文件,读取文件的所有行,然后关闭该文件。ReadAllLines(String,Encoding)打开一个文件,使用指定的

c++ - 异常 : bad_weak_ptr while shared_from_this

当我这样做时出现异常:std::bad_weak_ptr->shared_from_this()templateclasspainter_record_t{.......private:std::shared_ptr_owner;}这里我想在构造函数中设置“问题”对象:templateclassstream_record_t:publicpainter_record_t{public:stream_record_t(std::shared_ptrowner):painter_record_t(owner){//...}}我有基类:classi_painter_t{public:virt

c++ - 对 `boost::iostreams::mapped_file_source::mapped_file_source()' 的 undefined reference

我正在测试boost的内存映射文件,但是一旦我声明了一个boost::iostreams::mapped_file,就像在这个程序中一样:#include//definesff_pipelineandff_Pipe#include#include#include#include#include#include#include#include"MapReduceJob.hpp"usingnamespaceff;intmain(intargc,char*argv[]){boost::iostreams::mapped_filemf;}使用这个makefile:#FastflowandBoo

c++ - 我可以跨 DLL 边界传递 FILE 对象吗?

我有一个C++框架,其中一些计算被委托(delegate)给(有时是自动生成的)C函数或具有外部“C”链接的C++函数。这些是低级例程,必须以极快的速度和最小的开销进行评估,它们通常驻留在单独的共享对象/DLL中。他们目前的签名是这样的:intmy_generated_function(constdouble*input,double*output,double*work);它将驻留在共享库中,在POSIX上使用dlopen或在Windows上使用LoadLibrary加载。在POSIX上使用dlsym(handle,"my_generated_function")或在Windows上

c++ - 返回 *this 和 this 之间的区别 - C++

ClassA{//Code...A&operator++(){//code..return____;}Aoperator++(){//code..return___;}我什么时候应该返回*this或this?我理解this是一个指针,*this是指针的取消引用,但是当函数需要通过引用或值来获取值时,我无法决定返回什么。 最佳答案 this在您的函数中属于A*类型,因此返回该类型不合适。*this在您的函数中属于A&类型,它可以绑定(bind)到A&或A。当重载前缀++运算符时,返回A&是函数的正常返回类型。

c++ - (makefile 错误)RTNETLINK 回答 : File exists

这是我的生成文件:delay:tcqdiscadddeveth0rootnetemdelay0mstest4_s_delay:delay./a.out10101231120|teeserver_delay.txt但是,我在执行makefile时遇到以下错误:root@superwii-laptop:/home/superwii/Desktop/Amogh#maketest4_s_delaytcqdiscadddeveth0rootnetemdelay0msRTNETLINKanswers:Fileexistsmake:***[delay]Error2我无法克服这个错误。请帮忙。

c++ - type_info 不考虑 cv 限定符 : is this right?

这段代码打印1是正确的行为还是g++4.5的怪癖?#include#includeusingnamespacestd;intmain(){structA{};cout我认为cv限定符的不同类型作为非常不同的类型受到威胁,即使较少的cv限定类型可以隐式转换为更多cv限定的类型。 最佳答案 typeid根据C++标准(摘自ISO/IEC14882:2003的§5.2.8)忽略cv限定符:Thetop-levelcv-qualifiersofthelvalueexpressionorthetype-idthatistheoperandof