Repalced auto_ptr with unique_ptr.

This commit is contained in:
U.G. Wilson 2015-05-26 17:13:50 -05:00
parent 2703ef784d
commit bdfb87b461
8 changed files with 17 additions and 17 deletions

View File

@ -122,7 +122,7 @@ class YAML_CPP_API Emitter : private noncopyable {
bool CanEmitNewline() const; bool CanEmitNewline() const;
private: private:
std::auto_ptr<EmitterState> m_pState; std::unique_ptr<EmitterState> m_pState;
ostream_wrapper m_stream; ostream_wrapper m_stream;
}; };

View File

@ -40,8 +40,8 @@ class YAML_CPP_API Parser : private noncopyable {
void HandleTagDirective(const Token& token); void HandleTagDirective(const Token& token);
private: private:
std::auto_ptr<Scanner> m_pScanner; std::unique_ptr<Scanner> m_pScanner;
std::auto_ptr<Directives> m_pDirectives; std::unique_ptr<Directives> m_pDirectives;
}; };
} }

View File

@ -124,7 +124,7 @@ void EmitterState::StartedGroup(GroupType::value type) {
const int lastGroupIndent = (m_groups.empty() ? 0 : m_groups.top().indent); const int lastGroupIndent = (m_groups.empty() ? 0 : m_groups.top().indent);
m_curIndent += lastGroupIndent; m_curIndent += lastGroupIndent;
std::auto_ptr<Group> pGroup(new Group(type)); std::unique_ptr<Group> pGroup(new Group(type));
// transfer settings (which last until this group is done) // transfer settings (which last until this group is done)
pGroup->modifiedSettings = m_modifiedSettings; pGroup->modifiedSettings = m_modifiedSettings;
@ -149,7 +149,7 @@ void EmitterState::EndedGroup(GroupType::value type) {
// get rid of the current group // get rid of the current group
{ {
std::auto_ptr<Group> pFinishedGroup = m_groups.pop(); std::unique_ptr<Group> pFinishedGroup = m_groups.pop();
if (pFinishedGroup->type != type) if (pFinishedGroup->type != type)
return SetError(ErrorMsg::UNMATCHED_GROUP_TAG); return SetError(ErrorMsg::UNMATCHED_GROUP_TAG);
} }

View File

@ -29,12 +29,12 @@ class ptr_stack : private YAML::noncopyable {
std::size_t size() const { return m_data.size(); } std::size_t size() const { return m_data.size(); }
bool empty() const { return m_data.empty(); } bool empty() const { return m_data.empty(); }
void push(std::auto_ptr<T> t) { void push(std::unique_ptr<T> &t) {
m_data.push_back(NULL); m_data.push_back(NULL);
m_data.back() = t.release(); m_data.back() = t.release();
} }
std::auto_ptr<T> pop() { std::unique_ptr<T> pop() {
std::auto_ptr<T> t(m_data.back()); std::unique_ptr<T> t(m_data.back());
m_data.pop_back(); m_data.pop_back();
return t; return t;
} }

View File

@ -31,7 +31,7 @@ class ptr_vector : private YAML::noncopyable {
std::size_t size() const { return m_data.size(); } std::size_t size() const { return m_data.size(); }
bool empty() const { return m_data.empty(); } bool empty() const { return m_data.empty(); }
void push_back(std::auto_ptr<T> t) { void push_back(std::unique_ptr<T> &t) {
m_data.push_back(NULL); m_data.push_back(NULL);
m_data.back() = t.release(); m_data.back() = t.release();
} }

View File

@ -233,7 +233,7 @@ const RegEx& Scanner::GetValueRegex() const {
void Scanner::StartStream() { void Scanner::StartStream() {
m_startedStream = true; m_startedStream = true;
m_simpleKeyAllowed = true; m_simpleKeyAllowed = true;
std::auto_ptr<IndentMarker> pIndent(new IndentMarker(-1, IndentMarker::NONE)); std::unique_ptr<IndentMarker> pIndent(new IndentMarker(-1, IndentMarker::NONE));
m_indentRefs.push_back(pIndent); m_indentRefs.push_back(pIndent);
m_indents.push(&m_indentRefs.back()); m_indents.push(&m_indentRefs.back());
} }
@ -281,7 +281,7 @@ Scanner::IndentMarker* Scanner::PushIndentTo(int column,
if (InFlowContext()) if (InFlowContext())
return 0; return 0;
std::auto_ptr<IndentMarker> pIndent(new IndentMarker(column, type)); std::unique_ptr<IndentMarker> pIndent(new IndentMarker(column, type));
IndentMarker& indent = *pIndent; IndentMarker& indent = *pIndent;
const IndentMarker& lastIndent = *m_indents.top(); const IndentMarker& lastIndent = *m_indents.top();

View File

@ -20,7 +20,7 @@ class Setting {
Setting() : m_value() {} Setting() : m_value() {}
const T get() const { return m_value; } const T get() const { return m_value; }
std::auto_ptr<SettingChangeBase> set(const T& value); std::unique_ptr<SettingChangeBase> set(const T& value);
void restore(const Setting<T>& oldSetting) { m_value = oldSetting.get(); } void restore(const Setting<T>& oldSetting) { m_value = oldSetting.get(); }
private: private:
@ -49,8 +49,8 @@ class SettingChange : public SettingChangeBase {
}; };
template <typename T> template <typename T>
inline std::auto_ptr<SettingChangeBase> Setting<T>::set(const T& value) { inline std::unique_ptr<SettingChangeBase> Setting<T>::set(const T& value) {
std::auto_ptr<SettingChangeBase> pChange(new SettingChange<T>(this)); std::unique_ptr<SettingChangeBase> pChange(new SettingChange<T>(this));
m_value = value; m_value = value;
return pChange; return pChange;
} }
@ -75,11 +75,11 @@ class SettingChanges : private noncopyable {
(*it)->pop(); (*it)->pop();
} }
void push(std::auto_ptr<SettingChangeBase> pSettingChange) { void push(std::unique_ptr<SettingChangeBase> pSettingChange) {
m_settingChanges.push_back(pSettingChange.release()); m_settingChanges.push_back(pSettingChange.release());
} }
// like std::auto_ptr - assignment is transfer of ownership // like std::unique_ptr - assignment is transfer of ownership
SettingChanges& operator=(SettingChanges& rhs) { SettingChanges& operator=(SettingChanges& rhs) {
if (this == &rhs) if (this == &rhs)
return *this; return *this;

View File

@ -53,7 +53,7 @@ class SingleDocParser : private noncopyable {
private: private:
Scanner& m_scanner; Scanner& m_scanner;
const Directives& m_directives; const Directives& m_directives;
std::auto_ptr<CollectionStack> m_pCollectionStack; std::unique_ptr<CollectionStack> m_pCollectionStack;
typedef std::map<std::string, anchor_t> Anchors; typedef std::map<std::string, anchor_t> Anchors;
Anchors m_anchors; Anchors m_anchors;