On 07/26/2017 09:15 PM, Phil Bouchard wrote:
On 07/25/2017 08:11 AM, Phil Bouchard wrote:

I didn't have a chance to create documentation yesterday but I will this
week.

I just created a more complex example and it seems to be running
perfectly fine:

class Document
{
    auto head = nullptr<Document>();
    auto tail = nullptr<Document>();

    Document() { cout << __PRETTY_FUNCTION__ << endl; }
    ~Document() { cout << __PRETTY_FUNCTION__ << endl; }

    auto foo = function (int argument) { cout << __PRETTY_FUNCTION__ <<
endl; return argument; };
};

int main()
{
    auto temporary = 1;

    auto document = new Document();
    document.foo(temporary);

    auto bar = function ()
    {
        auto document = new Document();

        // cycle
        document.head = new Document();
        document.head.head = new Document();
        document.head.head.head = document;

        return document;
    };

    cout << 1 << endl;
    auto result = bar().foo(temporary);
    cout << 2 << endl;
}


Outputs:

Document::Document(const boost::node_proxy&)
auto __lambda0(boost::node_proxy&, int)
1
Document::Document(const boost::node_proxy&)
Document::Document(const boost::node_proxy&)
Document::Document(const boost::node_proxy&)
Document::~Document()
Document::~Document()
auto __lambda0(boost::node_proxy&, int)
2
Document::~Document()
Document::~Document()

Sorry I just fixed the last bug there can be and now the output correctly shows the following:

Document::Document(const boost::node_proxy&)
auto __lambda0(boost::node_proxy&, int)
1
Document::Document(const boost::node_proxy&)
Document::Document(const boost::node_proxy&)
Document::Document(const boost::node_proxy&)
auto __lambda0(boost::node_proxy&, int)
2
Document::~Document()
Document::~Document()
Document::~Document()
Document::~Document()

This is because all the elements in a certain "branch" get upscaled to a higher scope and therefore will all get deleted in that specific scope.


Thanks,
-Phil

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to