Merge remote-tracking branch 'hjanetzek/no-boost' into no-boost
This commit is contained in:
commit
95bb6a18f9
@ -127,7 +127,10 @@ void EmitterState::StartedGroup(GroupType::value type) {
|
|||||||
std::unique_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;
|
//
|
||||||
|
// NB: if pGroup->modifiedSettings == m_modifiedSettings,
|
||||||
|
// m_modifiedSettings is not changed!
|
||||||
|
pGroup->modifiedSettings = std::move(m_modifiedSettings);
|
||||||
|
|
||||||
// set up group
|
// set up group
|
||||||
if (GetFlowType(type) == Block)
|
if (GetFlowType(type) == Block)
|
||||||
@ -136,7 +139,7 @@ void EmitterState::StartedGroup(GroupType::value type) {
|
|||||||
pGroup->flowType = FlowType::Flow;
|
pGroup->flowType = FlowType::Flow;
|
||||||
pGroup->indent = GetIndent();
|
pGroup->indent = GetIndent();
|
||||||
|
|
||||||
m_groups.push(pGroup);
|
m_groups.push(std::move(pGroup));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitterState::EndedGroup(GroupType::value type) {
|
void EmitterState::EndedGroup(GroupType::value type) {
|
||||||
|
|||||||
@ -18,36 +18,40 @@ template <typename T>
|
|||||||
class ptr_stack : private YAML::noncopyable {
|
class ptr_stack : private YAML::noncopyable {
|
||||||
public:
|
public:
|
||||||
ptr_stack() {}
|
ptr_stack() {}
|
||||||
~ptr_stack() { clear(); }
|
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
for (std::size_t i = 0; i < m_data.size(); i++)
|
|
||||||
delete m_data[i];
|
|
||||||
m_data.clear();
|
m_data.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
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::unique_ptr<T> &t) {
|
void push(std::unique_ptr<T>&& t) {
|
||||||
m_data.push_back(NULL);
|
m_data.push_back(std::move(t));
|
||||||
m_data.back() = t.release();
|
|
||||||
}
|
}
|
||||||
std::unique_ptr<T> pop() {
|
std::unique_ptr<T> pop() {
|
||||||
std::unique_ptr<T> t(m_data.back());
|
std::unique_ptr<T> t(std::move(m_data.back()));
|
||||||
m_data.pop_back();
|
m_data.pop_back();
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
T& top() { return *m_data.back(); }
|
|
||||||
const T& top() const { return *m_data.back(); }
|
|
||||||
|
|
||||||
T& top(std::ptrdiff_t diff) { return **(m_data.end() - 1 + diff); }
|
T& top() {
|
||||||
|
return *(m_data.back().get());
|
||||||
|
}
|
||||||
|
const T& top() const {
|
||||||
|
return *(m_data.back().get());
|
||||||
|
}
|
||||||
|
|
||||||
|
T& top(std::ptrdiff_t diff) {
|
||||||
|
return *((m_data.end() - 1 + diff)->get());
|
||||||
|
}
|
||||||
|
|
||||||
const T& top(std::ptrdiff_t diff) const {
|
const T& top(std::ptrdiff_t diff) const {
|
||||||
return **(m_data.end() - 1 + diff);
|
return *((m_data.end() - 1 + diff)->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<T*> m_data;
|
std::vector<std::unique_ptr<T>> m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
#endif // PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
|
||||||
|
|||||||
@ -20,29 +20,30 @@ template <typename T>
|
|||||||
class ptr_vector : private YAML::noncopyable {
|
class ptr_vector : private YAML::noncopyable {
|
||||||
public:
|
public:
|
||||||
ptr_vector() {}
|
ptr_vector() {}
|
||||||
~ptr_vector() { clear(); }
|
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
for (std::size_t i = 0; i < m_data.size(); i++)
|
|
||||||
delete m_data[i];
|
|
||||||
m_data.clear();
|
m_data.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
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::unique_ptr<T> &t) {
|
void push_back(std::unique_ptr<T>&& t) {
|
||||||
m_data.push_back(NULL);
|
m_data.push_back(std::move(t));
|
||||||
m_data.back() = t.release();
|
|
||||||
}
|
}
|
||||||
T& operator[](std::size_t i) { return *m_data[i]; }
|
T& operator[](std::size_t i) { return *m_data[i]; }
|
||||||
const T& operator[](std::size_t i) const { return *m_data[i]; }
|
const T& operator[](std::size_t i) const { return *m_data[i]; }
|
||||||
|
|
||||||
T& back() { return *m_data.back(); }
|
T& back() {
|
||||||
const T& back() const { return *m_data.back(); }
|
return *(m_data.back().get());
|
||||||
|
}
|
||||||
|
|
||||||
|
const T& back() const {
|
||||||
|
return *(m_data.back().get());
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<T*> m_data;
|
std::vector<std::unique_ptr<T>> m_data;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -234,7 +234,7 @@ void Scanner::StartStream() {
|
|||||||
m_startedStream = true;
|
m_startedStream = true;
|
||||||
m_simpleKeyAllowed = true;
|
m_simpleKeyAllowed = true;
|
||||||
std::unique_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(std::move(pIndent));
|
||||||
m_indents.push(&m_indentRefs.back());
|
m_indents.push(&m_indentRefs.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ Scanner::IndentMarker* Scanner::PushIndentTo(int column,
|
|||||||
|
|
||||||
// and then the indent
|
// and then the indent
|
||||||
m_indents.push(&indent);
|
m_indents.push(&indent);
|
||||||
m_indentRefs.push_back(pIndent);
|
m_indentRefs.push_back(std::move(pIndent));
|
||||||
return &m_indentRefs.back();
|
return &m_indentRefs.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -62,10 +62,6 @@ class SettingChanges : private noncopyable {
|
|||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
restore();
|
restore();
|
||||||
|
|
||||||
for (setting_changes::const_iterator it = m_settingChanges.begin();
|
|
||||||
it != m_settingChanges.end(); ++it)
|
|
||||||
delete *it;
|
|
||||||
m_settingChanges.clear();
|
m_settingChanges.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,22 +72,22 @@ class SettingChanges : private noncopyable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void push(std::unique_ptr<SettingChangeBase> pSettingChange) {
|
void push(std::unique_ptr<SettingChangeBase> pSettingChange) {
|
||||||
m_settingChanges.push_back(pSettingChange.release());
|
m_settingChanges.push_back(std::move(pSettingChange));
|
||||||
}
|
}
|
||||||
|
|
||||||
// like std::unique_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;
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
m_settingChanges = rhs.m_settingChanges;
|
std::swap(m_settingChanges, rhs.m_settingChanges);
|
||||||
rhs.m_settingChanges.clear();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector<SettingChangeBase*> setting_changes;
|
typedef std::vector<std::unique_ptr<SettingChangeBase>> setting_changes;
|
||||||
setting_changes m_settingChanges;
|
setting_changes m_settingChanges;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user