I have used the std::unique_ptr in my previous codes in Visual studio 2013 preview, and I don't have the problems there. For my recent project case, it is compiler error less in debugging in visual studio 2012. So now I only got the following errors
This is the line that having the issue:
std::unique_ptr<MyClass> classHolder;
The following are what the compiler says
'unique_ptr' : is not a member of 'std'
syntax error : missing ';' before '<'
missing type specifier - int assumed. Note: C++ does not support
default-intunexpected token(s) preceding ';'
Any thought on how can I resolve this issue?
Sample:
#include <memory>
#include <string>
#include <sstream>
#include <boost/weak_ptr.hpp>
#include "JSAPIAuto.h"
#include "MyClass.h"
#ifndef H_CLASSHAVINGPROB
#define H_CLASSHAVINGPROB
class ClassHavingProb : public FB::JSAPIAuto //ClassHavingProb: this is the wrapper class if you are familiar with FireBreath(C++ to Javascript)
{
public:
ClassHavingProb()
{
obj = std::unique_ptr<MyClass>(new MyClass(1));
//MyClass: this is the class reponsible for the functionalities, I've used unique_ptr so that class lifecycle will not be very problematic. If I used a regular pointer the class is not properly dismissed.
//Some more init codes here
}
~ClassHavingProb() {
obj.release(); //the class must be dismissed
}
private:
std::unique_ptr<MyClass> obj;
};
#endif // H_CLASSHAVINGPROB
Well, since FireBreath has to run on older browsers that don't have the C++11 standard I don't know how to fix the issue you're describing directly, but you could just use a boost scoped_ptr type instead of unique_ptr.