Trouble with SmartPtr and DestructiveCopy

  • Vasily Simonov

    Vasily Simonov - 2008-10-13

    I have trouble with SmartPtr<T, DestructiveCopy> using VS 2005 SP1.
    Here is the code that doesn't compile:

    #include "loki\SmartPtr.h"

    class TestClass { };

    typedef SmartPtr<TestClass, DestructiveCopy> AutoPtr;

    AutoPtr TestAutoPtr() {
        return new TestClass();

    int main(int argc, char* argv[])
        AutoPtr temp = TestAutoPtr(); // here is an error
        // error C3892: 'val' : you cannot assign to a variable that is const  (int smartptr.h line: 706 )

        return 0;

    What's wrong?


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks