Simplified the MixinVector class so that it no longer supports custom allocators,

instead just uses std::vector<>'s default allocators.
This commit is contained in:
Robert Osfield 2008-06-27 12:44:41 +00:00
parent 34f58482e6
commit 1057d74a11
2 changed files with 35 additions and 47 deletions

View File

@ -24,10 +24,10 @@ namespace osg {
* *
* @author Neil Groves * @author Neil Groves
*/ */
template<class ValueT, class AllocatorT=std::allocator<ValueT> > template<class ValueT>
class MixinVector class MixinVector
{ {
typedef typename std::vector<ValueT, AllocatorT> vector_type; typedef typename std::vector<ValueT> vector_type;
public: public:
typedef typename vector_type::allocator_type allocator_type; typedef typename vector_type::allocator_type allocator_type;
typedef typename vector_type::value_type value_type; typedef typename vector_type::value_type value_type;
@ -42,27 +42,18 @@ public:
typedef typename vector_type::size_type size_type; typedef typename vector_type::size_type size_type;
typedef typename vector_type::difference_type difference_type; typedef typename vector_type::difference_type difference_type;
explicit MixinVector(const allocator_type& alloc = allocator_type()) explicit MixinVector() : _impl()
: _impl(alloc)
{ {
} }
explicit MixinVector(size_type initial_size, const value_type& fill_value = value_type()) explicit MixinVector(size_type initial_size, const value_type& fill_value = value_type())
: _impl(initial_size, fill_value) : _impl(initial_size, fill_value)
{ {
} }
MixinVector(size_type initial_size,
const value_type& fill_value,
const allocator_type& alloc)
: _impl(initial_size, fill_value, alloc)
{
}
template<class InputIterator> template<class InputIterator>
MixinVector(InputIterator first, InputIterator last, MixinVector(InputIterator first, InputIterator last)
const allocator_type& alloc = allocator_type()) : _impl(first, last)
: _impl(first, last, alloc)
{ {
} }
@ -90,9 +81,6 @@ public:
virtual ~MixinVector() {} virtual ~MixinVector() {}
operator const vector_type&() const { return _impl; }
operator vector_type&() { return _impl; }
void clear() { _impl.clear(); } void clear() { _impl.clear(); }
void resize(size_type new_size, const value_type& fill_value = value_type()) { _impl.resize(new_size, fill_value); } void resize(size_type new_size, const value_type& fill_value = value_type()) { _impl.resize(new_size, fill_value); }
void reserve(size_type new_capacity) { _impl.reserve(new_capacity); } void reserve(size_type new_capacity) { _impl.reserve(new_capacity); }
@ -153,54 +141,54 @@ public:
vector_type& asVector() { return _impl; } vector_type& asVector() { return _impl; }
const vector_type& asVector() const { return _impl; } const vector_type& asVector() const { return _impl; }
friend inline bool operator==(const MixinVector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left._impl == right._impl; } friend inline bool operator==(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl == right._impl; }
friend inline bool operator==(const MixinVector<ValueT, AllocatorT>& left, const std::vector<ValueT, AllocatorT>& right) { return left._impl == right; } friend inline bool operator==(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl == right; }
friend inline bool operator==(const std::vector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left == right._impl; } friend inline bool operator==(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left == right._impl; }
friend inline bool operator!=(const MixinVector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left._impl != right._impl; } friend inline bool operator!=(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl != right._impl; }
friend inline bool operator!=(const MixinVector<ValueT, AllocatorT>& left, const std::vector<ValueT, AllocatorT>& right) { return left._impl != right; } friend inline bool operator!=(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl != right; }
friend inline bool operator!=(const std::vector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left != right._impl; } friend inline bool operator!=(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left != right._impl; }
friend inline bool operator<(const MixinVector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left._impl < right._impl; } friend inline bool operator<(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl < right._impl; }
friend inline bool operator<(const MixinVector<ValueT, AllocatorT>& left, const std::vector<ValueT, AllocatorT>& right) { return left._impl < right; } friend inline bool operator<(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl < right; }
friend inline bool operator<(const std::vector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left < right._impl; } friend inline bool operator<(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left < right._impl; }
friend inline bool operator>(const MixinVector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left._impl > right._impl; } friend inline bool operator>(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl > right._impl; }
friend inline bool operator>(const MixinVector<ValueT, AllocatorT>& left, const std::vector<ValueT, AllocatorT>& right) { return left._impl > right; } friend inline bool operator>(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl > right; }
friend inline bool operator>(const std::vector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left > right._impl; } friend inline bool operator>(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left > right._impl; }
friend inline bool operator<=(const MixinVector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left._impl <= right._impl; } friend inline bool operator<=(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl <= right._impl; }
friend inline bool operator<=(const MixinVector<ValueT, AllocatorT>& left, const std::vector<ValueT, AllocatorT>& right) { return left._impl <= right; } friend inline bool operator<=(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl <= right; }
friend inline bool operator<=(const std::vector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left <= right._impl; } friend inline bool operator<=(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left <= right._impl; }
friend inline bool operator>=(const MixinVector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left._impl >= right._impl; } friend inline bool operator>=(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl >= right._impl; }
friend inline bool operator>=(const MixinVector<ValueT, AllocatorT>& left, const std::vector<ValueT, AllocatorT>& right) { return left._impl >= right; } friend inline bool operator>=(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl >= right; }
friend inline bool operator>=(const std::vector<ValueT, AllocatorT>& left, const MixinVector<ValueT, AllocatorT>& right) { return left >= right._impl; } friend inline bool operator>=(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left >= right._impl; }
private: private:
vector_type _impl; vector_type _impl;
}; };
template<class ValueT, class AllocatorT> inline template<class ValueT> inline
void void
swap(MixinVector<ValueT, AllocatorT>& left, swap(MixinVector<ValueT>& left,
MixinVector<ValueT, AllocatorT>& right) MixinVector<ValueT>& right)
{ {
std::swap(left.asVector(), right.asVector()); std::swap(left.asVector(), right.asVector());
} }
template<class ValueT, class AllocatorT> inline template<class ValueT> inline
void void
swap(MixinVector<ValueT, AllocatorT>& left, swap(MixinVector<ValueT>& left,
std::vector<ValueT, AllocatorT>& right) std::vector<ValueT>& right)
{ {
std::swap(left.asVector(), right); std::swap(left.asVector(), right);
} }
template<class ValueT, class AllocatorT> inline template<class ValueT> inline
void void
swap(std::vector<ValueT, AllocatorT>& left, swap(std::vector<ValueT>& left,
MixinVector<ValueT, AllocatorT>& right) MixinVector<ValueT>& right)
{ {
std::swap(left, right.asVector()); std::swap(left, right.asVector());
} }

View File

@ -508,9 +508,9 @@ class OSG_EXPORT HeightField : public Shape
/** Get the const sFloatArray height data.*/ /** Get the const sFloatArray height data.*/
const osg::FloatArray* getFloatArray() const { return _heights.get(); } const osg::FloatArray* getFloatArray() const { return _heights.get(); }
HeightList& getHeightList() { return *_heights; } HeightList& getHeightList() { return _heights->asVector(); }
const HeightList& getHeightList() const { return *_heights; } const HeightList& getHeightList() const { return _heights->asVector(); }
/** Set the height of the skirt to render around the edge of HeightField. /** Set the height of the skirt to render around the edge of HeightField.
* The skirt is used as a means of disguising edge boundaries between adjacent HeightField, * The skirt is used as a means of disguising edge boundaries between adjacent HeightField,