<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Use unique_ptr with struct and AcDbObjectPointer&amp;lt;AcDbLine&amp;gt; correctly ? in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11371171#M2369</link>
    <description>Right, I only use the custom class for new objects, and when I want to use the entity's constructor, otherwise I use AcDbObjectPointer and the objectId.&lt;BR /&gt;&lt;BR /&gt;DBOBJPTR_EXPOSE_PTR_REF is better explained here,&lt;BR /&gt;&lt;A href="https://www.keanw.com/2008/04/automatic-closi.html" target="_blank"&gt;https://www.keanw.com/2008/04/automatic-closi.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-RefGuide-AcDbSmartObjectPointer" target="_blank"&gt;https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-RefGuide-AcDbSmartObjectPointer&lt;/A&gt;&lt;BR /&gt;I may have incorrectly assume that this would add reference counting, to act more like a shared pointer</description>
    <pubDate>Sun, 21 Aug 2022 00:34:00 GMT</pubDate>
    <dc:creator>daniel_cadext</dc:creator>
    <dc:date>2022-08-21T00:34:00Z</dc:date>
    <item>
      <title>Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11347740#M2358</link>
      <description>&lt;P&gt;Good morning everyone , i 'm writting a program to draw some frames . Inside it i 'm using C++ Smartpointer unique_ptr with struct&amp;nbsp; .then inside this struct i have some ObjectARX Smartpointer AcDbObjectPointer&amp;lt;AcDbLine&amp;gt; like&amp;nbsp;below. Is there any problems with this kind of using ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance !&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="trithuongle_0-1660013570835.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1101778i598F1CD195552C1C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="trithuongle_0-1660013570835.png" alt="trithuongle_0-1660013570835.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 02:56:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11347740#M2358</guid>
      <dc:creator>trithuongle</dc:creator>
      <dc:date>2022-08-09T02:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11348396#M2359</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yeah,&amp;nbsp; they will be destructed, but your intent isn’t clear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you’re just creating the lines, then you can just use some AcGePoint3d, AcGeVector3d or even AcGeLineSeg3d&lt;/P&gt;&lt;P&gt;If you need to track the objects over time, it’s better to store the ObjectId&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 09:58:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11348396#M2359</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2022-08-09T09:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11359154#M2360</link>
      <description>&lt;P&gt;Bear in mind that &lt;FONT face="courier new,courier"&gt;AcDbObjectPointer&lt;/FONT&gt;s can't be copied:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;template&amp;lt;class T_OBJECT&amp;gt; class AcDbObjectPointer {
    // Copy and assignment prohibited.
    AcDbObjectPointer(const AcDbObjectPointer &amp;amp;) = delete;
    AcDbObjectPointer&amp;amp; operator=(const AcDbObjectPointer &amp;amp;) = delete;
};
&lt;/LI-CODE&gt;
&lt;P&gt;Thus an instance of your struct standard can't be copied. This won't compile:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;standard s1;
standard s2 = s1; //error C2280: standard::standard(const standard&amp;amp;): Tried to use a deleted function
&lt;/LI-CODE&gt;
&lt;P&gt;Could it be that this is the reason why you want to use &lt;FONT face="courier new,courier"&gt;unique_ptr&lt;/FONT&gt;s?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree with&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8575899"&gt;@daniel_cadext&lt;/a&gt;: Using&amp;nbsp;&lt;FONT face="courier new,courier"&gt;AcDbObjectPointer&lt;/FONT&gt;s with &lt;FONT face="courier new,courier"&gt;unique_ptr&lt;/FONT&gt;s will "work".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I think it is dangerous because it might foil the intend of the &lt;FONT face="courier new,courier"&gt;AcDbObjectPointer&lt;/FONT&gt;: To close an object as soon as the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;AcDbObjectPointer&lt;/FONT&gt; is deleted. This might especially happen if you copy the &lt;FONT face="courier new,courier"&gt;unique_ptr&lt;/FONT&gt;&amp;nbsp;that points to the &lt;FONT face="courier new,courier"&gt;struct&lt;/FONT&gt; with&amp;nbsp;&lt;FONT face="courier new,courier"&gt;AcDbObjectPointer&lt;/FONT&gt;s. This will postpone the deletion to the point where all &lt;FONT face="courier new,courier"&gt;unique_ptr&lt;/FONT&gt;s are out of scope.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 07:39:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11359154#M2360</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2022-08-15T07:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11359495#M2361</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8575899"&gt;@daniel_cadext&lt;/a&gt;&amp;nbsp;Thanks for your reply.&lt;/P&gt;&lt;P&gt;Sorry for my explanation is not clear enough.&lt;/P&gt;&lt;P&gt;My&amp;nbsp;&lt;SPAN&gt;intent is i want to draw a group of lines (like a frame) but i don't want to remember about close or delete these lines .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then , i also want&amp;nbsp; this group of lines has a few accompanying information to reuse after (height &amp;amp; angle).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So that i chose the struct to store AcDbObjectPointer&amp;lt;AcDbLine&amp;gt; and some above information .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then in turn the struct-type object , i want to dynamic allocate this by smartpointer .&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;So that i decided to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;use unique_ptr .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 11:51:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11359495#M2361</guid>
      <dc:creator>trithuongle</dc:creator>
      <dc:date>2022-08-15T11:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11359501#M2362</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/845950"&gt;@tbrammer&lt;/a&gt;&amp;nbsp;Thanks for your reply .&lt;/P&gt;&lt;P&gt;There 's 1 thing in your reply that i haven't understand yet .&lt;/P&gt;&lt;P&gt;"___&lt;SPAN&gt;This might especially happen if you copy the&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;unique_ptr&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;that points to the&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;struct&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;with&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;AcDbObjectPointer&lt;/FONT&gt;&lt;SPAN&gt;s. This will postpone the deletion to the point where all&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;unique_ptr&lt;/FONT&gt;&lt;SPAN&gt;s are out of scope."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope that you can make it more detail or give me a code example .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance !&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 11:50:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11359501#M2362</guid>
      <dc:creator>trithuongle</dc:creator>
      <dc:date>2022-08-15T11:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11360027#M2363</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I didn't consider that a &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;unique_ptr&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;EM&gt;can't&lt;/EM&gt;&amp;nbsp; be copied - just like an &lt;FONT face="courier new,courier"&gt;AcDbObjectPointer&lt;/FONT&gt;. So my statement doesn't make sense.&amp;nbsp;It would make sense for&amp;nbsp;&lt;FONT face="courier new,courier"&gt;shared_ptr&lt;/FONT&gt;s.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Sorry for that and thanks for pointing it out.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 15:44:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11360027#M2363</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2022-08-15T15:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11361288#M2364</link>
      <description>&lt;P&gt;FYI, new headers have a definition DBOBJPTR_EXPOSE_PTR_REF that enables ref counting&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 06:44:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11361288#M2364</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2022-08-16T06:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11361294#M2365</link>
      <description>&lt;P&gt;Also you can create a custom delete for std::unique_ptr, kind of handy sometimes I.e.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;template &amp;lt;class T&amp;gt;
class DBObjectDeleter
{
public:
    inline void operator()(T *p)
    {
        if (p != nullptr)
            return this-&amp;gt;close(p);
    }
private:
    inline void close(T *p)
    {
        if (!p-&amp;gt;objectId().isNull())
            p-&amp;gt;close();
        else
            this-&amp;gt;deleter(p);
    }
    inline void deleter(T *p)
    {
        delete p;
        p = nullptr;
    }
};

template&amp;lt;typename T&amp;gt;
using unique_dbo_ptr = std::unique_ptr&amp;lt;T, DBObjectDeleter&amp;lt;T&amp;gt;&amp;gt;;
using AcDbLineUPtr = unique_dbo_ptr&amp;lt;AcDbLine&amp;gt;;

//usage
AcDbLineUPtr ptr(new  AcDbLine({ 0,0,0 }, { 100, 100, 100 }));&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 16 Aug 2022 06:47:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11361294#M2365</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2022-08-16T06:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11370591#M2366</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/845950"&gt;@tbrammer&lt;/a&gt;&amp;nbsp; sorry for late reply .&lt;/P&gt;&lt;P&gt;so that i think i can understand it.&lt;/P&gt;&lt;P&gt;Again, thank for your explanation !&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 12:50:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11370591#M2366</guid>
      <dc:creator>trithuongle</dc:creator>
      <dc:date>2022-08-20T12:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11370592#M2367</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8575899"&gt;@daniel_cadext&lt;/a&gt;&amp;nbsp;Sorry for late reply.&lt;/P&gt;&lt;P&gt;Can you explain more about "&lt;SPAN&gt;DBOBJPTR_EXPOSE_PTR_REF" with example ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance !&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 12:52:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11370592#M2367</guid>
      <dc:creator>trithuongle</dc:creator>
      <dc:date>2022-08-20T12:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11370602#M2368</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8575899"&gt;@daniel_cadext&lt;/a&gt;&amp;nbsp;Thank for your suggestion .&lt;/P&gt;&lt;P&gt;So that i think with this custom class . We could use it instead of "AcDbObjectPointer&amp;lt;AcDbLine&amp;gt;" sometimes.&lt;/P&gt;&lt;P&gt;Nice solution !&lt;/P&gt;&lt;P&gt;But let me confirm again about this .&lt;/P&gt;&lt;P&gt;According to your custom class ,i think your intent is create a custom deleter in unique_ptr .So that when the unique_ptr object goes out of its scope , it call the deleter , then if the internal pointer is not null then close the internal pointer , else just delete it ?&lt;/P&gt;&lt;P&gt;This is quite similar to ObjectARX 's AcDbObjectPointer &amp;lt;T class&amp;gt;right ?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 13:03:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11370602#M2368</guid>
      <dc:creator>trithuongle</dc:creator>
      <dc:date>2022-08-20T13:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11371171#M2369</link>
      <description>Right, I only use the custom class for new objects, and when I want to use the entity's constructor, otherwise I use AcDbObjectPointer and the objectId.&lt;BR /&gt;&lt;BR /&gt;DBOBJPTR_EXPOSE_PTR_REF is better explained here,&lt;BR /&gt;&lt;A href="https://www.keanw.com/2008/04/automatic-closi.html" target="_blank"&gt;https://www.keanw.com/2008/04/automatic-closi.html&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-RefGuide-AcDbSmartObjectPointer" target="_blank"&gt;https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-RefGuide-AcDbSmartObjectPointer&lt;/A&gt;&lt;BR /&gt;I may have incorrectly assume that this would add reference counting, to act more like a shared pointer</description>
      <pubDate>Sun, 21 Aug 2022 00:34:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11371171#M2369</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2022-08-21T00:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Use unique_ptr with struct and AcDbObjectPointer&lt;AcDbLine&gt; correctly ?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11387548#M2370</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8575899"&gt;@daniel_cadext&lt;/a&gt;&amp;nbsp;Thank you alot for detailed instructions . i will continue to work on it .&lt;/P&gt;&lt;P&gt;Sincerely !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 12:21:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/use-unique-ptr-with-struct-and-acdbobjectpointer-lt-acdbline-gt/m-p/11387548#M2370</guid>
      <dc:creator>trithuongle</dc:creator>
      <dc:date>2022-08-29T12:21:57Z</dc:date>
    </item>
  </channel>
</rss>

