6 #ifndef ZEROBUF_BASEVECTOR_H
7 #define ZEROBUF_BASEVECTOR_H
9 #include <zerobuf/Types.h>
24 template<
class A,
class T >
35 const T& operator[] (
size_t index )
const;
37 bool empty()
const {
return _getSize() == 0; }
38 uint64_t size()
const {
return _getSize() /
sizeof(T); }
40 {
return _parent->template getDynamic< const T >( _index ); }
42 bool operator == (
const BaseVector& rhs )
const;
43 bool operator != (
const BaseVector& rhs )
const;
50 size_t _getSize()
const {
return _parent->getDynamicSize( _index ); }
54 template<
class A,
class T >
inline
60 template<
class A,
class T >
inline
64 throw std::runtime_error(
"Vector out of bounds read" );
66 return data()[ index ];
69 template<
class A,
class T >
inline
70 bool BaseVector< A, T >::operator == (
const BaseVector& rhs )
const
74 const size_t size_ = _getSize();
75 if( size_ == 0 || size_ != rhs._getSize( ))
77 return ::memcmp( data(), rhs.data(), size_ ) == 0;
80 template<
class A,
class T >
inline
81 bool BaseVector< A, T >::operator != (
const BaseVector& rhs )
const
83 return !(operator == ( rhs ));
86 template<
class A,
class T >
inline
87 std::ostream& operator << ( std::ostream& os,
88 const BaseVector< A, T >& vector )
90 return os <<
typeid( vector ).name() <<
" of size " << vector.size();