mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Replace Boost usage with C++11 features
- Adds 'std=c++11' compiler flags - Replaces boost::type_traits with std::type_traits - Replaces boost::shared_ptr with std::shared_ptr - Replaces std::auto_ptr with std::unique_ptr - Replaces raw pointers with std::unique_ptr in ptr_vector, ptr_stack, and SettingChanges - Replaces boost::noncopyable with deleted copy and assignment operators - Replaces boost::next with std::next - Replaces boost::enable_if with std::enable_if - Replaces boost::is_convertible with std::is_convertible - Replaces ptrdiff_t with std::ptrdiff_t - Replaces boost::iterator_facade and boost::iterator_adaptor with std::iterator, borrowing the 'proxy reference' technique from boost - Removes Boost dependency from CMakeLists - Formats changed files using clang-format
This commit is contained in:
@@ -20,7 +20,7 @@ class Setting {
|
||||
Setting() : 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(); }
|
||||
|
||||
private:
|
||||
@@ -49,8 +49,8 @@ class SettingChange : public SettingChangeBase {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline std::auto_ptr<SettingChangeBase> Setting<T>::set(const T& value) {
|
||||
std::auto_ptr<SettingChangeBase> pChange(new SettingChange<T>(this));
|
||||
inline std::unique_ptr<SettingChangeBase> Setting<T>::set(const T& value) {
|
||||
std::unique_ptr<SettingChangeBase> pChange(new SettingChange<T>(this));
|
||||
m_value = value;
|
||||
return pChange;
|
||||
}
|
||||
@@ -62,10 +62,6 @@ class SettingChanges : private noncopyable {
|
||||
|
||||
void clear() {
|
||||
restore();
|
||||
|
||||
for (setting_changes::const_iterator it = m_settingChanges.begin();
|
||||
it != m_settingChanges.end(); ++it)
|
||||
delete *it;
|
||||
m_settingChanges.clear();
|
||||
}
|
||||
|
||||
@@ -75,23 +71,23 @@ class SettingChanges : private noncopyable {
|
||||
(*it)->pop();
|
||||
}
|
||||
|
||||
void push(std::auto_ptr<SettingChangeBase> pSettingChange) {
|
||||
m_settingChanges.push_back(pSettingChange.release());
|
||||
void push(std::unique_ptr<SettingChangeBase> pSettingChange) {
|
||||
m_settingChanges.push_back(std::move(pSettingChange));
|
||||
}
|
||||
|
||||
// like std::auto_ptr - assignment is transfer of ownership
|
||||
SettingChanges& operator=(SettingChanges& rhs) {
|
||||
// like std::unique_ptr - assignment is transfer of ownership
|
||||
SettingChanges& operator=(SettingChanges&& rhs) {
|
||||
if (this == &rhs)
|
||||
return *this;
|
||||
|
||||
clear();
|
||||
m_settingChanges = rhs.m_settingChanges;
|
||||
rhs.m_settingChanges.clear();
|
||||
std::swap(m_settingChanges, rhs.m_settingChanges);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::vector<SettingChangeBase*> setting_changes;
|
||||
typedef std::vector<std::unique_ptr<SettingChangeBase>> setting_changes;
|
||||
setting_changes m_settingChanges;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user