From 55f7c6da84f5368373e46945e4f6bee28f53cb81 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 12 Feb 2013 11:01:50 +0200 Subject: Workarounds for non-standard Sun CC STL --- odb/vector.ixx | 199 +++++++++++++++++++++++---------------------------------- 1 file changed, 81 insertions(+), 118 deletions(-) (limited to 'odb/vector.ixx') diff --git a/odb/vector.ixx b/odb/vector.ixx index 1fd9a1b..b23238b 100644 --- a/odb/vector.ixx +++ b/odb/vector.ixx @@ -4,14 +4,11 @@ namespace odb { - // - // vector - // - // construct/copy/destroy: // - template - inline vector& vector:: + template + inline vector& + vector:: operator= (const vector& x) { v_ = x.v_; @@ -20,9 +17,9 @@ namespace odb return *this; } - template + template template - inline void vector:: + inline void vector:: assign (I f, I l) { v_.assign (f, l); @@ -30,8 +27,8 @@ namespace odb impl_.assign (v_.size ()); } - template - inline void vector:: + template + inline void vector:: assign (size_type n, const T& u) { v_.assign (n, u); @@ -40,8 +37,9 @@ namespace odb } #ifdef ODB_CXX11 - template - inline vector& vector:: + template + inline vector& + vector:: operator=(vector&& x) { v_ = std::move (x.v_); @@ -51,8 +49,9 @@ namespace odb } #ifdef ODB_CXX11_INITIALIZER_LIST - template - inline vector& vector:: + template + inline vector& + vector:: operator= (std::initializer_list il) { v_ = il; @@ -61,8 +60,8 @@ namespace odb return *this; } - template - inline void vector:: + template + inline void vector:: assign (std::initializer_list il) { v_.assign (il); @@ -74,8 +73,9 @@ namespace odb // iterators: // - template - inline typename vector::base_iterator_type vector:: + template + inline typename vector::base_iterator_type + vector:: mbegin () { if (_tracking ()) @@ -83,8 +83,10 @@ namespace odb return v_.begin (); } - template - inline typename vector::base_reverse_iterator_type vector:: + template + inline + typename vector::base_reverse_iterator_type + vector:: mrbegin () { if (_tracking ()) @@ -94,8 +96,8 @@ namespace odb // capacity: // - template - inline void vector:: + template + inline void vector:: resize (size_type n) { v_.resize (n); @@ -103,8 +105,8 @@ namespace odb impl_.resize (n); } - template - inline void vector:: + template + inline void vector:: resize (size_type n, const T& c) { v_.resize (n, c); @@ -112,8 +114,8 @@ namespace odb impl_.resize (n); } - template - inline void vector:: + template + inline void vector:: reserve (size_type n) { v_.reserve (n); @@ -122,8 +124,8 @@ namespace odb } #ifdef ODB_CXX11 - template - inline void vector:: + template + inline void vector:: shrink_to_fit () { v_.shrink_to_fit (); @@ -133,8 +135,9 @@ namespace odb // element access: // - template - inline typename vector::reference vector:: + template + inline typename vector::reference + vector:: modify (size_type n) { reference r (v_[n]); @@ -143,8 +146,9 @@ namespace odb return r; } - template - inline typename vector::reference vector:: + template + inline typename vector::reference + vector:: modify_at (size_type n) { reference r (v_.at (n)); @@ -153,8 +157,9 @@ namespace odb return r; } - template - inline typename vector::reference vector:: + template + inline typename vector::reference + vector:: modify_front () { reference r (v_.front ()); @@ -163,8 +168,9 @@ namespace odb return r; } - template - inline typename vector::reference vector:: + template + inline typename vector::reference + vector:: modify_back () { reference r (v_.back ()); @@ -174,8 +180,8 @@ namespace odb } #ifdef ODB_CXX11 - template - inline T* vector:: + template + inline T* vector:: modify_data() /*noexcept*/ { if (_tracking ()) @@ -186,8 +192,8 @@ namespace odb // modifiers: // - template - inline void vector:: + template + inline void vector:: push_back (const T& x) { v_.push_back (x); @@ -195,8 +201,8 @@ namespace odb impl_.push_back (); } - template - inline void vector:: + template + inline void vector:: pop_back () { v_.pop_back (); @@ -204,8 +210,9 @@ namespace odb impl_.pop_back (); } - template - inline typename vector::iterator vector:: + template + inline typename vector::iterator + vector:: insert (iterator p, const T& x) { if (_tracking ()) @@ -213,8 +220,8 @@ namespace odb return iterator (this, v_.insert (p.base (), x)); } - template - inline void vector:: + template + inline void vector:: insert (iterator p, size_type n, const T& x) { if (_tracking ()) @@ -222,9 +229,9 @@ namespace odb v_.insert (p.base (), n, x); } - template + template template - inline void vector:: + inline void vector:: insert (iterator p, I f, I l) { size_type i, n; @@ -240,8 +247,9 @@ namespace odb impl_.insert (i, v_.size () - n); } - template - inline typename vector::iterator vector:: + template + inline typename vector::iterator + vector:: erase (iterator p) { if (_tracking ()) @@ -249,8 +257,9 @@ namespace odb return iterator (this, v_.erase (p.base ())); } - template - inline typename vector::iterator vector:: + template + inline typename vector::iterator + vector:: erase (iterator f, iterator l) { if (_tracking ()) @@ -259,16 +268,16 @@ namespace odb return iterator (this, v_.erase (f.base (), l.base ())); } - template - inline void vector:: + template + inline void vector:: swap (vector& x) { v_.swap (x.v_); vector_base::swap (x); } - template - inline void vector:: + template + inline void vector:: clear () { v_.clear (); @@ -277,8 +286,8 @@ namespace odb } #ifdef ODB_CXX11 - template - inline void vector:: + template + inline void vector:: push_back(T&& x) { v_.push_back (std::move (x)); @@ -286,8 +295,9 @@ namespace odb impl_.push_back (); } - template - inline typename vector::iterator vector:: + template + inline typename vector::iterator + vector:: insert (iterator p, T&& x) { base_iterator_type r (v_.insert (p.base (), std::move (x))); @@ -297,9 +307,9 @@ namespace odb } #ifdef ODB_CXX11_VARIADIC_TEMPLATE - template + template template - inline void vector:: + inline void vector:: emplace_back (Args&&... args) { v_.push_back (std::forward (args)...); @@ -307,9 +317,10 @@ namespace odb impl_.push_back (); } - template + template template - inline typename vector::iterator vector:: + inline typename vector::iterator + vector:: emplace (iterator p, Args&&... args) { base_iterator_type r ( @@ -323,8 +334,9 @@ namespace odb // Interfacing with base vector. // - template - inline vector& vector:: + template + inline vector& + vector:: operator= (const base_vector_type& x) { v_ = x; @@ -334,8 +346,9 @@ namespace odb } #ifdef ODB_CXX11 - template - inline vector& vector:: + template + inline vector& + vector:: operator= (base_vector_type&& x) { v_ = std::move (x); @@ -344,54 +357,4 @@ namespace odb return *this; } #endif - - // - // vector_iterator - // - - template - inline typename vector_iterator::reference vector_iterator:: - modify () const - { - if (v_->_tracking ()) - v_->_impl ().modify (static_cast (i_ - v_->base ().begin ())); - return *i_; - } - - template - inline typename vector_iterator::reference vector_iterator:: - modify (difference_type n) const - { - if (v_->_tracking ()) - v_->_impl ().modify ( - static_cast (i_ - v_->base ().begin () + n)); - return i_[n]; - } - - // - // vector_iterator - // - - template - inline typename vector_iterator >::reference - vector_iterator >:: - modify () const - { - if (v_->_tracking ()) - v_->_impl ().modify ( - static_cast (v_->base ().rend () - i_ - 1)); - return *i_; - } - - template - inline typename vector_iterator >::reference - vector_iterator >:: - modify (difference_type n) const - { - if (v_->_tracking ()) - // Note: going in the opposite direction. - v_->_impl ().modify ( - static_cast (v_->base ().rend () - i_ - 1 - n)); - return i_[n]; - } } -- cgit v1.1