Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
为什么调用shared_from_this会调用std::terminate
考虑这段代码 class A public std enable shared from this a public std shared ptr a f return shared from this int main A a std s
c
C11
sharedptr
C17
cstandardlibrary
提升shared_from_this和析构函数
我发现不允许在类的析构函数中调用shared from this https svn boost org trac boost ticket 147 https svn boost org trac boost ticket 147 此行为
c
boost
sharedptr
objectlifetime
weakptr
如何减少大量包装类的实现代码?
我正在开发一个包含一些类的库 我们称它们为C1 C2 and Cn 这些类中的每一个都实现一些接口 即I1 I2 Im n gt m 库中对象之间的关系很复杂 我必须 为我的库用户提供一些 API 以使用智能指针访问这些对象 经过一番讨论
c
C11
sharedptr
smartpointers
weakptr
从shared_ptr 中分离指针? [复制]
这个问题在这里已经有答案了 可能的重复 如何从 boost shared ptr 释放指针 https stackoverflow com questions 1525764 how to release pointer from boos
c
boost
sharedptr
C++ 多态性和指针向量问题
考虑以下示例代码 class Foo class Bar public Foo class FooCollection protected vector
c
vector
polymorphism
sharedptr
如何推迟shared_ptr的删除操作?
我创建了一个指针sample主要类 我正在将此指针传递给函数function1 该函数必须使用指针作为共享指针并使用该指针执行一些操作 退出期间function1 的析构函数sample由于调用shared ptr 当我将相同的指针传递给不
c
pointers
sharedptr
smartpointers
如何从 boost 库中取出单个元素(例如共享指针)?
我一直在尝试一些 Boost 组件 我认为在我正在从事的项目中直接需要的唯一一个是boost shared ptr 仅仅包含所需的文件会很困难吗 shared ptr 或者至少在我的项目中包含 Boost smart ptr 目录的文件 它
c
boost
sharedptr
boostsmartptr
Shared_ptr 和 unique_ptr 有例外
From en cppreference com http en cppreference com w cpp memory unique ptr std unique ptr 的典型用途包括 提供异常安全 处理具有动态生命周期的对象的类和
c
Exception
sharedptr
uniqueptr
返回指向 const 对象的 const 共享指针的 const 向量
给出以下基于共享指针容器的类 class Foo class Bar public const std vector
c
STL
constants
sharedptr
Make_shared - 自己的实现
我正在尝试自己实现shared ptr 我有以下问题make shared 主要特点是std make shared它在连续的内存块中分配计数器块和对象 我怎样才能做同样的事情 我尝试做类似的事情 template
c
sharedptr
具有 malloc 和 free 的共享指针
我在包含 c 和 cpp 的大型应用程序中工作 所有文件都保存为 cpp 扩展名 但代码是用 c 风格编写的 我的意思是它是定义结构而不是类通过 malloc 和 realloc 和 calloc 分配内存 最近他们安装了 boost 库所
c
boost
sharedptr
scopedptr
为什么我不应该总是使用shared_ptr和unique_ptr而应该使用普通指针?
我有以下背景C and obj c所以 RC GC 是我 仍然 珍视的东西 当我开始学习时C 更深入地说 我不停地想知道为什么我会使用普通指针 当它们如此时不受管理的而不是其他替代解决方案 the 共享指针提供了一种存储引用的好方法 并且在
c
sharedptr
uniqueptr
将shared_ptr
传递为shared_ptr
通过考试的最佳方法是什么shared ptr派生类型的函数 该函数采用shared ptr基本类型 我一般都会通过shared ptr通过引用避免不必要的复制 int foo const shared ptr
c
casting
C11
sharedptr
smartpointers
我的API函数应该采用shared_ptr还是weak_ptr
我目前正在设计一个 API 我不确定我的函数是否应该采用shared ptr or weak ptr 有些小部件包含查看器 观众有一个功能add painter这为观看者添加了一位画家 当查看器需要重绘时 它使用其绘制器绘制到缓冲区并显示结
c
sharedptr
weakptr
std::shared_ptrs 的自定义删除器
创建后是否可以使用自定义删除器std shared ptr不使用new 我的问题是对象创建是由工厂类处理的 并且它的构造函数和析构函数受到保护 这会产生编译错误 我不想使用new因为它的缺点 详细说明 我更喜欢创建这样的共享指针 它不允许您
c
sharedptr
smartpointers
使用shared_ptr和glutInit会导致分段错误
经询问this https stackoverflow com questions 33855611 defining shared ptr causes segfault cmake在我尝试了很多东西并发现问题与 glutInit 有关之
c
C11
gcc
sharedptr
glut
使用受保护的析构函数删除对象
我必须为类编写一个共享指针 它必须做的许多其他事情之一是确保它可以删除它所指向的对象 如何编写适用于具有受保护析构函数的对象的解决方案 此外 如果该对象是使用放置新创建的 我不应该调用delete在对象上 因为该空间可能仍在使用中 将del
c
C11
sharedptr
shared_ptr 释放[重复]
这个问题在这里已经有答案了 可能的重复 如何从 boost shared ptr 释放指针 https stackoverflow com questions 1525764 how to release pointer from boos
c
sharedptr
C11
std::shared_ptr 向上转换为基类 - 最好的方法?
哪种转换更好 有什么区别 class Base class Derived public Base public std enable shared from this
c
sharedptr
std::allocate_shared 使用什么类型来分配内存?
From https en cppreference com w cpp memory shared ptr allocate shared https en cppreference com w cpp memory shared ptr
c
C11
sharedptr
dynamicmemoryallocation
allocator
«
1
2
3
4
5
6
7
»