Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
如何在 C++ 中维护指向父级的弱指针?
是否有一种标准方法可以在 C 的子对象中维护指向父对象 使用共享指针创建 的弱指针 本质上 我需要实现以下内容 Class B Class A private B m b Class B public void SetParentPtr c
c
smartpointers
weakreferences
std::shared_ptrs 的自定义删除器
创建后是否可以使用自定义删除器std shared ptr不使用new 我的问题是对象创建是由工厂类处理的 并且它的构造函数和析构函数受到保护 这会产生编译错误 我不想使用new因为它的缺点 详细说明 我更喜欢创建这样的共享指针 它不允许您
c
sharedptr
smartpointers
引用和 Box
在内存中的表示方式有什么区别?
我试图了解参考文献和Box
Rust
reference
smartpointers
unique_ptr 具有需要原始指针的 API?
使用托管内存和函数式语言大约 10 年之后 我终于回到了 C 智能指针让我感到困惑 一半的文档仍然是关于已弃用的auto ptr 我正在尝试实现这个相当简单的项目符号 你好世界 http bulletphysics org mediawik
c
C11
smartpointers
是否可以继承 C++11 智能指针并覆盖相关运算符?
根据cppreference com http en cppreference com w cpp memory shared ptr std shared ptr提供了一整套相对运算符 出于某些目的 我更希望使用相对运算符来根据比较引用的
c
inheritance
C11
operatoroverloading
smartpointers
带有 addrinfo 结构的智能指针
我需要处理两个结构addrinfo指针 由于我使用 C 11 进行编码 因此我必须使代码异常安全 事实上 我的构造函数可能会抛出一个runtime error 当你不再需要那种结构时 你应该调用freeaddrinfo为了释放结构内的列表
Sockets
C11
smartpointers
C++ Protobuf 添加已分配的重复数字字段
我有一条简单的消息 其中包含大量重复的数字字段 syntax proto3 option cc enable arenas true message bigData repeated double info 1 在运行时 数据到达时已经分配
c
protocolbuffers
smartpointers
protobufc
unique_ptr::get() 而不是 &* 有什么用?
我在用着unique ptr管理一些资源以便在任何情况下都能安全销毁 等等 void do something BLOB b unique ptr
c
pointers
smartpointers
uniqueptr
将 std::unique_ptr 返回到多态类对象的正确方法
假设我有以下类层次结构 struct Base struct Derived public Base void DoStuffSpecificToDerivedClass 以及以下工厂方法 std unique ptr factoryMet
c
smartpointers
uniqueptr
C++ 11:智能指针的使用[重复]
这个问题在这里已经有答案了 使用 smart 的最佳实践是什么 在某些情况下我应该更喜欢使用原始指针而不是智能指针 例如 如果我知道 A 类创建了 B 类并且是 B 类的唯一所有者 是否有理由使用智能指针 如果您知道有关该主题的任何好文章
c
C11
sharedptr
smartpointers
有CUDA智能指针吗?
如果没有 释放的标准方法是什么cudaMalloc当抛出异常时ed内存 请注意 我无法使用 Thrust 您可以使用RAII http en wikipedia org wiki Resource Acquisition Is Initia
memory
CUDA
GPGPU
smartpointers
unique_ptr 运算符=
std unique ptr
c
visualstudio2010
C11
smartpointers
std::shared_ptr 初始化:make_shared
() vs shared_ptr
(new Foo) [重复]
这个问题在这里已经有答案了 有什么区别 std shared ptr
c
C11
sharedptr
smartpointers
为什么我要 std::move std::shared_ptr?
我一直在寻找铿锵源码 https clang llvm org doxygen CompilerInstance 8cpp source html l00069我发现了这个片段 void CompilerInstance setInvoca
c
C11
sharedptr
smartpointers
movesemantics
避免非虚拟析构函数的对象切片
我正在为智能指针编写代码作为练习 使用在线教程 1 http www davethehat com articles smartp htm 2 http www codeproject com Articles 15351 Implemen
c
templates
pointers
g
smartpointers
为什么不能从 unique_ptr 构造出weak_ptr?
如果我理解正确的话 weak ptr不会增加托管对象的引用计数 因此它不代表所有权 它只是让您访问一个对象 该对象的生命周期由其他人管理 所以我真的不明白为什么weak ptr不能由unique ptr 但只有一个shared ptr 有人
c
sharedptr
smartpointers
uniqueptr
weakptr
boost的shared_ptr(shared_ptr
const & r, T * p)有什么用?
boost shared ptr有一个不寻常的构造函数 template
c
boost
sharedptr
smartpointers
静态对象上的shared_ptr好吗?
我想知道静态对象上的智能指针是否合理 例如 假设我有一些静态资源 并且想要将该静态资源的引用传递给需要这些资源使用的其他对象 一种方法是使用指向该资源的原始指针 但现在我想知道智能指针 shared ptr 是否是更好的方法 如果是 如何正
c
C11
pointers
static
smartpointers
C++ 智能指针性能
与裸指针相比 使用智能指针 尤其是 boost shared ptr 在时间和内存方面的成本要高多少 对于游戏 嵌入式系统的性能密集型部分 使用裸指针是否更好 您是否建议对性能密集型组件使用裸指针或智能指针 取消引用智能指针通常是微不足道的
c
boost
smartpointers
«
1
2
3
4
5
»