unique-ptr专题提供unique-ptr的最新资讯内容,帮你更好的了解unique-ptr。
我想让我的类对这个函数可迭代(假设我不能改变这个) <pre><code>// basically my class wrapped in a unique_ptr
这是我创建的类<​​/p> <pre><code>#include &lt;memory&gt; template &lt;typename T&gt; class binary_tree { private: T t_da
我正在处理一个存储在共享内存区域中并由 getter 返回的大对象。由于对象的大小,我遇到了按值返回对
我在处理一小段代码时遇到了一些麻烦,这让我有点困惑。我目前正在做一个速度很重要的项目,因此
我知道这是一个常见错误,但我不明白为什么在我当前的情况下会发生这种错误。我的子类从我的超类
我已经阅读了很多与此相关的问题,但无法回答我的问题。 我创建了一个类如下 - <pre><code>class
为什么这段代码无法编译? <pre><code>#include &lt;memory&gt; #include &lt;utility&gt; int foo() { auto num = std::mak
对于某些数据类型 <code>std::vector&lt;std::auto_ptr&lt;T&gt;&gt;</code>,<code>std::vector&lt;std::unique_ptr&lt;T&gt;&gt;</code
我有一个关于如何将 <code>unique_ptr</code> 与重载构造函数一起使用的问题。 这是我的类定义: <pr
我有一个 <code>Inner</code> 类,它应该由 <code>Outer</code> 类<em>唯一地</em>拥有,具体来说,除了 <code>Outer</co
我想知道在面向对象编程中使用 <code>std::unique_ptr</code> 的正确方法是什么。假设我有一个包含必须可以
我试图让一个结构拥有一个指向堆上对象的指针数组的指针。为了不必担心删除这些对象,我想使用智
我有一个将 const ref 返回到 std::unique_ptr 的函数。我从某个容器中得到这个 ptr。当我的 std::unique_ptr 容器
这个代码有什么“问题”,举个简单的例子? <pre><code>unique_ptr&lt;char&gt; meow = strdup(&#34;meow&#34;); </code>
我的问题与 <a href="https://stackoverflow.com/questions/66367777/how-to-write-a-template-function-that-adds-an-object-of-variant-cla
来自<a href="https://en.cppreference.com/w/cpp/memory/unique_ptr/reset" rel="nofollow noreferrer">https://en.cppreference.com/w/cpp/mem
我以这种方式使用 <code>std::unique_ptr</code>: <pre><code>template &lt;typename Pointer, auto deleter&gt; using my_unique_p
在下面的代码中,为什么需要<code>std::make_unique</code>来初始化<code>Foo::up_</code>?<br/> 具体来说,<strong>为
<pre><code>std::array&lt;unique_ptr&lt;SomeClass&gt;, 1000&gt; globalArray; void foo(int index) { globalArray[index] = make_unique&lt;So
我很难理解 unique_ptr 的默认值。<br/> 从 <a href="https://en.cppreference.com/w/cpp/memory/unique_ptr/unique_ptr" rel="nofollo