[Libreoffice-commits] core.git: sw/inc
Takeshi Abe
tabe at fixedpoint.jp
Mon Oct 24 04:00:15 UTC 2016
sw/inc/docary.hxx | 33 ++++++++++++++++++++++++++++-----
1 file changed, 28 insertions(+), 5 deletions(-)
New commits:
commit 02e6c1c95993740e0dbea724b3014348c4b6559d
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Fri Oct 21 18:42:26 2016 +0900
sw: Avoid inheritance from std::vector
Change-Id: I09ae81fa3fbd89060dd1a993952d9bb67ddb101e
Reviewed-on: https://gerrit.libreoffice.org/30125
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 58ee21f..91ec0e7 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -66,10 +66,13 @@ public:
};
template<typename Value>
-class SwVectorModifyBase : public std::vector<Value>
+class SwVectorModifyBase
{
public:
+ typedef typename std::vector<Value>::iterator iterator;
typedef typename std::vector<Value>::const_iterator const_iterator;
+ typedef typename std::vector<Value>::size_type size_type;
+ typedef typename std::vector<Value>::value_type value_type;
protected:
enum class DestructorPolicy {
@@ -78,6 +81,7 @@ protected:
};
private:
+ typename std::vector<Value> mvVals;
const DestructorPolicy mPolicy;
protected:
@@ -86,8 +90,27 @@ protected:
: mPolicy(policy) {}
public:
- using std::vector<Value>::begin;
- using std::vector<Value>::end;
+ bool empty() const { return mvVals.empty(); }
+ Value const& front() const { return mvVals.front(); }
+ size_t size() const { return mvVals.size(); }
+ iterator begin() { return mvVals.begin(); }
+ const_iterator begin() const { return mvVals.begin(); }
+ iterator end() { return mvVals.end(); }
+ const_iterator end() const { return mvVals.end(); }
+ void clear() { mvVals.clear(); }
+ iterator erase(iterator aIt) { return mvVals.erase(aIt); }
+ iterator erase(iterator aFirst, iterator aLast) { return mvVals.erase(aFirst, aLast); }
+ iterator insert(iterator aIt, Value const& rVal) { return mvVals.insert(aIt, rVal); }
+ template<typename TInputIterator>
+ void insert(iterator aIt, TInputIterator aFirst, TInputIterator aLast)
+ {
+ mvVals.insert(aIt, aFirst, aLast);
+ }
+ void push_back(Value const& rVal) { mvVals.push_back(rVal); }
+ void reserve(size_type nSize) { mvVals.reserve(nSize); }
+ Value const& at(size_type nPos) const { return mvVals.at(nPos); }
+ Value const& operator[](size_type nPos) const { return mvVals[nPos]; }
+ Value& operator[](size_type nPos) { return mvVals[nPos]; }
// free any remaining child objects based on mPolicy
virtual ~SwVectorModifyBase()
@@ -129,10 +152,10 @@ protected:
public:
virtual size_t GetFormatCount() const override
- { return std::vector<Value>::size(); }
+ { return SwVectorModifyBase<Value>::size(); }
virtual Value GetFormat(size_t idx) const override
- { return std::vector<Value>::operator[](idx); }
+ { return SwVectorModifyBase<Value>::operator[](idx); }
inline size_t GetPos(const SwFormat *p) const
{ return SwVectorModifyBase<Value>::GetPos( static_cast<Value>( const_cast<SwFormat*>( p ) ) ); }
More information about the Libreoffice-commits
mailing list