Skip to content
Snippets Groups Projects
Commit c5e023c5 authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Remove unused methods based on unsave casts

These constructors and assignments from base class are
all using a downcast which may result in undefined behaviour.
Since this is potentially dangerous and not used anywhere
in the core modules, this patch removes those methods.
parent dd4e07de
No related branches found
No related tags found
1 merge request!66Remove forbidden downcast
......@@ -426,27 +426,6 @@ namespace Dune {
for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
}
//! construct from base class object
base_array (const base_array_unmanaged<B,A>& _a)
{
const base_array& a = static_cast<const base_array&>(_a);
// allocate memory with same size as a
this->n = a.n;
if (this->n>0) {
this->p = allocator_.allocate(this->n);
new (this->p)B[this->n];
} else
{
this->n = 0;
this->p = 0;
}
// and copy elements
for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
}
//! free dynamic memory
~base_array ()
{
......@@ -510,12 +489,6 @@ namespace Dune {
return *this;
}
//! assign from base class object
base_array& operator= (const base_array_unmanaged<B,A>& a)
{
return this->operator=(static_cast<const base_array&>(a));
}
protected:
A allocator_;
......
......@@ -524,30 +524,6 @@ namespace Dune {
for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
}
//! construct from base class object
BlockVector (const block_vector_unmanaged<B,A>& _a)
{
// upcast, because protected data inaccessible
const BlockVector& a = static_cast<const BlockVector&>(_a);
// allocate memory with same size as a
this->n = a.n;
capacity_ = a.capacity_;
if (capacity_>0) {
this->p = this->allocator_.allocate(capacity_);
new (this->p)B[capacity_];
} else
{
this->n = 0;
this->p = 0;
capacity_ = 0;
}
// and copy elements
for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
}
//! free dynamic memory
~BlockVector ()
{
......@@ -591,13 +567,6 @@ namespace Dune {
return *this;
}
//! assign from base class object
BlockVector& operator= (const block_vector_unmanaged<B,A>& a)
{
// forward to regular assignement operator
return this->operator=(static_cast<const BlockVector&>(a));
}
//! assign from scalar
BlockVector& operator= (const field_type& k)
{
......@@ -706,18 +675,6 @@ namespace Dune {
this->p = a.p;
}
//! construct from base class object with reference semantics!
BlockVectorWindow (const block_vector_unmanaged<B,A>& _a)
{
// cast needed to access protected data
const BlockVectorWindow& a = static_cast<const BlockVectorWindow&>(_a);
// make me point to the other's data
this->n = a.n;
this->p = a.p;
}
//! assignment
BlockVectorWindow& operator= (const BlockVectorWindow& a)
{
......@@ -734,13 +691,6 @@ namespace Dune {
return *this;
}
//! assign from base class object
BlockVectorWindow& operator= (const block_vector_unmanaged<B,A>& a)
{
// forward to regular assignment operator
return this->operator=(static_cast<const BlockVectorWindow&>(a));
}
//! assign from scalar
BlockVectorWindow& operator= (const field_type& k)
{
......@@ -1098,19 +1048,6 @@ namespace Dune {
this->j = a.j;
}
//! construct from base class object with reference semantics!
CompressedBlockVectorWindow (const compressed_block_vector_unmanaged<B,A>& _a)
{
// cast needed to access protected data (downcast)
const CompressedBlockVectorWindow& a = static_cast<const CompressedBlockVectorWindow&>(_a);
// make me point to the other's data
this->n = a.n;
this->p = a.p;
this->j = a.j;
}
//! assignment
CompressedBlockVectorWindow& operator= (const CompressedBlockVectorWindow& a)
{
......@@ -1128,13 +1065,6 @@ namespace Dune {
return *this;
}
//! assign from base class object
CompressedBlockVectorWindow& operator= (const compressed_block_vector_unmanaged<B,A>& a)
{
// forward to regular assignment operator
return this->operator=(static_cast<const CompressedBlockVectorWindow&>(a));
}
//! assign from scalar
CompressedBlockVectorWindow& operator= (const field_type& k)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment