Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Trouble with SmartPtr and DestructiveCopy

Help
2008-10-13
2013-04-08
  • Vasily Simonov
    Vasily Simonov
    2008-10-13

    Hi
    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?