Skip to content
Snippets Groups Projects
Verified Commit dda63bcd authored by Ansgar Burchardt's avatar Ansgar Burchardt
Browse files

DynamicVector, FieldVector: add `data` member function

parent fda92a53
Branches
Tags
1 merge request!700dense vectors: add some more methods expected for containers
......@@ -156,6 +156,18 @@ namespace Dune {
return _data[i];
}
//! return pointer to underlying array
K* data() noexcept
{
return _data.data();
}
//! return pointer to underlying array
const K* data() const noexcept
{
return _data.data();
}
const container_type &container () const { return _data; }
container_type &container () { return _data; }
};
......
......@@ -196,6 +196,18 @@ namespace Dune {
DUNE_ASSERT_BOUNDS(i < SIZE);
return _data[i];
}
//! return pointer to underlying array
K* data() noexcept
{
return _data.data();
}
//! return pointer to underlying array
const K* data() const noexcept
{
return _data.data();
}
};
/** \brief Read a FieldVector from an input stream
......@@ -333,6 +345,18 @@ namespace Dune {
return _data;
}
//! return pointer to underlying array
K* data() noexcept
{
return &_data;
}
//! return pointer to underlying array
const K* data() const noexcept
{
return &_data;
}
//===== conversion operator
/** \brief Conversion operator */
......
......@@ -128,6 +128,7 @@ struct FieldVectorMainTestCommons
if (w.size() > 0) {
FVECTORTEST_ASSERT(!w.empty());
FVECTORTEST_ASSERT(std::addressof(w[0]) == std::addressof(w.front()));
FVECTORTEST_ASSERT(std::addressof(w[0]) == w.data());
FVECTORTEST_ASSERT(std::addressof(w[d-1]) == std::addressof(w.back()));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment