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:
Matt Blair
2015-04-27 16:58:38 -04:00
parent 4376ebacaa
commit 24fa1b3380
19 changed files with 160 additions and 107 deletions

View File

@@ -14,40 +14,45 @@
#include "yaml-cpp/noncopyable.h"
// TODO: This class is no longer needed
template <typename T>
class ptr_stack : private YAML::noncopyable {
public:
ptr_stack() {}
~ptr_stack() { clear(); }
void clear() {
for (std::size_t i = 0; i < m_data.size(); i++)
delete m_data[i];
m_data.clear();
}
std::size_t size() const { return m_data.size(); }
bool empty() const { return m_data.empty(); }
void push(std::auto_ptr<T> t) {
m_data.push_back(NULL);
m_data.back() = t.release();
void push(std::unique_ptr<T>&& t) {
m_data.push_back(std::move(t));
}
std::auto_ptr<T> pop() {
std::auto_ptr<T> t(m_data.back());
std::unique_ptr<T> pop() {
std::unique_ptr<T> t(std::move(m_data.back()));
m_data.pop_back();
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 {
return **(m_data.end() - 1 + diff);
return *((m_data.end() - 1 + diff)->get());
}
private:
std::vector<T*> m_data;
std::vector<std::unique_ptr<T>> m_data;
};
#endif // PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66