Go to the documentation of this file.
22 #ifndef __Vector_hpp__
23 #define __Vector_hpp__
47 template<
typename T,
typename Allocator>
55 template<
typename T,
typename Allocator = vecAllocator<T> >
58 public std::vector<T, Allocator>
66 using iterator =
typename vectorType::iterator;
80 using init_list =
typename std::initializer_list<T>;
129 this->assign(len, val);
162 this->assign(src.begin(), src.end());
180 Vector::assign(rhs.begin(), rhs.end());
203 return makeUnique<VectorType>(*
this);
210 return Ptr.release();
267 return vectorType::size();
273 return vectorType::capacity();
279 return vectorType::empty();
286 vectorType::reserve(cap);
290 void fill(
const T& val);
304 return span<T>(
const_cast<T*
>(this->data()), this->
size());
351 template<
typename T,
typename Allocator>
362 template<
typename T,
typename Allocator>
365 if( !ovec.
write(os) )
VectorType operator-() const
VectorType & VectorField()
typename vectorType::const_iterator const_iterator
VectorType & operator=(const VectorType &rhs)=default
Copy assignment.
const vectorType & vectorField() const
#define fatalExit
Fatal exit.
const auto & deviceVectorAll() const
bool readStdVector(iIstream &is, std::vector< T, Allocator > &vec)
VectorType * clonePtr() const
Clone as a pointer.
VectorType & operator=(const vectorType &rhs)
Copy assignment from std::vector.
void operator*=(const T &val)
bool read(iIstream &is, const IOPattern &iop)
void operator/=(const T &val)
Vector(const word &name, size_t len)
Vector with specified length and name.
const VectorType & VectorField() const
Access to this, mostly used by derived classes.
void reserve(size_t cap)
Reserve capacity for vector Preserve the content.
Vector< T, Allocator > VectorType
const word * const_pointer
Vector(const word &name, size_t cap, size_t len, RESERVE)
Vector with name, size and reserved capacity.
auto size() const
Size of the vector.
bool write(iOstream &os, const IOPattern &iop) const
static constexpr bool isHostAccessible()
void operator=(const T &val)
Scalar assignment.
~Vector()=default
Destructor.
Interface class for any input stream
Vector(const word &name, const vectorType &src, size_t cap)
Construct with a name and form std::vector (host memory) and with a desired capacity.
auto capacity() const
Capacity of the vector.
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
void operator+=(const T &val)
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
void operator-=(const T &val)
typename std::initializer_list< word > init_list
typename vectorType::reference reference
bool empty() const
If vector is empty.
virtual const word & name() const
Return the name of the stream.
Vector(const word &name, const Vector< T > &src)
Copy from src with a new name.
static constexpr bool isHostAccessible_
bool write(iOstream &os) const
typename vectorType::const_reference const_reference
const word & name() const
Name of the vector.
const auto & deviceVector() const
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
Vector(const word &name, size_t len, const T &val)
Vector with name, length and value.
int32 lineNumber() const
Const access to the current stream line number.
typename vectorType::iterator iterator
typename std::vector< word, vecAllocator< word > > vectorType
Vector(const word &name, const vectorType &src)
Construct with a name and form std::vector (host memory)
TypeInfoTemplateNV111("Vector", T, memoerySpaceName())
static constexpr const char * memoerySpaceName()
Interface class for any output stream.
Vector(const word &name, const init_list &l)
Vector from name and initializer list.
vectorType & vectorField()
uniquePtr< VectorType > clone() const
Clone as a uniquePtr.
bool writeStdVector(iOstream &os, const std::vector< T, Allocator > &vec)
Vector(const word &name)
Empty Vector with a name.