diff options
author | 2016-03-12 12:31:13 +0100 | |
---|---|---|
committer | 2016-03-12 12:31:13 +0100 | |
commit | a026a582f1a0ea8c1ede3acaddacef506ef3f3b0 (patch) | |
tree | e31573822f2359677de519f9f3b600d98e8764cd /src/lib/util/vecstream.h | |
parent | 477d2abd43984f076b7e45f5527591fa8fd0d241 (diff) | |
parent | dcab55bf53b94713a6f72e9633f5101c8dd6c08c (diff) |
Merge pull request #15 from mamedev/master
Sync to base master
Diffstat (limited to 'src/lib/util/vecstream.h')
-rw-r--r-- | src/lib/util/vecstream.h | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/lib/util/vecstream.h b/src/lib/util/vecstream.h index fb472df95cd..bf144501253 100644 --- a/src/lib/util/vecstream.h +++ b/src/lib/util/vecstream.h @@ -19,6 +19,10 @@ #include <algorithm> #include <cassert> +#include <ios> +#include <istream> +#include <ostream> +#include <memory> #include <ostream> #include <streambuf> #include <string> @@ -103,15 +107,16 @@ public: void swap(basic_vectorbuf &that) { + using std::swap; std::basic_streambuf<CharT, Traits>::swap(that); - std::swap(m_mode, that.m_mode); - m_storage.swap(that.m_storage); - std::swap(m_threshold, that.m_threshold); + swap(m_mode, that.m_mode); + swap(m_storage, that.m_storage); + swap(m_threshold, that.m_threshold); } void reserve(typename vector_type::size_type size) { - if ((m_mode & std::ios_base::out) && (m_storage.size() < size)) + if ((m_mode & std::ios_base::out) && (m_storage.capacity() < size)) { m_storage.reserve(size); adjust(); @@ -145,8 +150,8 @@ protected: bool const out(which & std::ios_base::out); if ((!in && !out) || (in && out && (std::ios_base::cur == dir)) || - (in && (!(m_mode & std::ios_base::in) || !this->gptr())) || - (out && (!(m_mode & std::ios_base::out) || !this->pptr()))) + (in && !(m_mode & std::ios_base::in)) || + (out && !(m_mode & std::ios_base::out))) { return pos_type(off_type(-1)); } @@ -382,6 +387,16 @@ typedef basic_ovectorstream<wchar_t> wovectorstream; typedef basic_vectorstream<char> vectorstream; typedef basic_vectorstream<wchar_t> wvectorstream; +template <typename CharT, typename Traits, typename Allocator> +void swap(basic_vectorbuf<CharT, Traits, Allocator> &a, basic_vectorbuf<CharT, Traits, Allocator> &b) { a.swap(b); } + +template <typename CharT, typename Traits, typename Allocator> +void swap(basic_ivectorstream<CharT, Traits, Allocator> &a, basic_ivectorstream<CharT, Traits, Allocator> &b) { a.swap(b); } +template <typename CharT, typename Traits, typename Allocator> +void swap(basic_ovectorstream<CharT, Traits, Allocator> &a, basic_ovectorstream<CharT, Traits, Allocator> &b) { a.swap(b); } +template <typename CharT, typename Traits, typename Allocator> +void swap(basic_vectorstream<CharT, Traits, Allocator> &a, basic_vectorstream<CharT, Traits, Allocator> &b) { a.swap(b); } + } // namespace util #endif // __MAME_UTIL_VECSTREAM_H__ |