diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-25 17:35:00 +1100 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-25 17:35:00 +1100 |
commit | 69537686be13f6ff84ce79e84374351e943ab21b (patch) | |
tree | de4bef9b5ace623b59751447b9131046483d2388 /src/include/rustic.hpp | |
parent | 27b0292ca6828eed7e782a57ad4d641f0ebf7357 (diff) | |
parent | 753a2f44cc4c00b952cddae2ceed066ebb18a470 (diff) | |
download | mrust-69537686be13f6ff84ce79e84374351e943ab21b.tar.gz |
Merge branch 'master' of https://github.com/thepowersgang/mrustc
Diffstat (limited to 'src/include/rustic.hpp')
-rw-r--r-- | src/include/rustic.hpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/include/rustic.hpp b/src/include/rustic.hpp index 5d768152..93992f61 100644 --- a/src/include/rustic.hpp +++ b/src/include/rustic.hpp @@ -24,11 +24,11 @@ public: m_first(ptr), m_len(len) {} - + ::std::vector<T> to_vec() const { return ::std::vector<T>(begin(), end()); } - + unsigned int size() const { return m_len; } @@ -42,7 +42,7 @@ public: assert(ofs + len <= m_len); return slice { m_first + ofs, len }; } - + T* begin() const { return m_first; } T* end() const { return m_first + m_len; } @@ -73,7 +73,7 @@ class option { char m_data[ sizeof(T) ]; bool m_set; - + void* data_ptr() { return m_data; } const void* data_ptr() const { return m_data; } public: @@ -90,15 +90,15 @@ public: reinterpret_cast<T*>(data_ptr())->~T(); } } - + bool is_none() const { return !m_set; } bool is_some() const { return m_set; } - + const T& unwrap() const { assert(is_some()); return *reinterpret_cast<const T*>(m_data); } - + void if_set(::std::function<void (const T&)> f) const { if( m_set ) { return f(m_data); @@ -125,7 +125,7 @@ public: option(): m_ptr(nullptr) {} - + bool is_none() const { return m_ptr == nullptr; } bool is_some() const { return m_ptr != nullptr; } T& unwrap() const { |