diff --git a/dune/istl/basearray.hh b/dune/istl/basearray.hh index 8cdccd5eea8e3b8bcce91f5ab2da79db184b71df..bc0d8a3ca945867c28c0b76442d18b02e5b7f192 100644 --- a/dune/istl/basearray.hh +++ b/dune/istl/basearray.hh @@ -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_; diff --git a/dune/istl/bvector.hh b/dune/istl/bvector.hh index cd988809b6b7f9f367b5f8a2123c4427ebe0f738..71d51e3b7afedc956d3cdc7a13552bde9bf02bb5 100644 --- a/dune/istl/bvector.hh +++ b/dune/istl/bvector.hh @@ -25,6 +25,8 @@ namespace Dune { + template<class B, class A=std::allocator<B> > + class BlockVectorWindow; /** \brief An unmanaged vector of blocks. @@ -524,30 +526,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 +569,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) { @@ -605,6 +576,17 @@ namespace Dune { (static_cast<block_vector_unmanaged<B,A>&>(*this)) = k; return *this; } + + //! Assignment from BlockVectorWindow + template<class OtherAlloc> + BlockVector& operator= (const BlockVectorWindow<B,OtherAlloc>& other) + { + resize(other.size()); + for(std::size_t i=0; i<other.size(); ++i) + (*this)[i] = other[i]; + return *this; + } + protected: size_type capacity_; @@ -655,7 +637,11 @@ namespace Dune { Setting the compile time switch DUNE_ISTL_WITH_CHECKING enables error checking. */ +#ifndef DOXYGEN + template<class B, class A> +#else template<class B, class A=std::allocator<B> > +#endif class BlockVectorWindow : public block_vector_unmanaged<B,A> { public: @@ -706,18 +692,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 +708,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 +1065,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 +1082,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) { diff --git a/dune/istl/test/basearraytest.cc b/dune/istl/test/basearraytest.cc index c7da73a57961a3dfc70e28b1fe53f4ca7c01a70e..2695d05d9d5a4403d179c213085f1264c6ae106a 100644 --- a/dune/istl/test/basearraytest.cc +++ b/dune/istl/test/basearraytest.cc @@ -11,9 +11,6 @@ int main() base_array<double> v1(10); base_array<double> v2 = v1; - // Test constructor from base_array_unmanaged - base_array<double> v3 = *(static_cast<base_array_unmanaged<double>*>(&v1)); - v1.resize(20); v1 = v2; diff --git a/dune/istl/test/bvectortest.cc b/dune/istl/test/bvectortest.cc index b250531d1dc1e42742d34cbba3a0c51f93c401de..99f3fe09791803116bb30369d01e1e909cb1eda0 100644 --- a/dune/istl/test/bvectortest.cc +++ b/dune/istl/test/bvectortest.cc @@ -61,11 +61,6 @@ int testVector() for(typename Vector::size_type i=0; i < v.N(); ++i) assert(v[i] == w[i]); - w = static_cast<const Dune::block_vector_unmanaged<VectorBlock,Alloc>&>(v); - - for(typename Vector::size_type i=0; i < w.N(); ++i) - assert(v[i] == w[i]); - Vector z(w); assert(w.N()==z.N()); @@ -74,15 +69,6 @@ int testVector() for(typename Vector::size_type i=0; i < w.N(); ++i) assert(z[i] == w[i]); - Vector z1(static_cast<const Dune::block_vector_unmanaged<VectorBlock,Alloc>&>(v2)); - - assert(v2.N()==z1.N()); - assert(v2.capacity()==z1.capacity()); - - for(typename Vector::size_type i=1; i < v2.N(); ++i) { - assert(z1[i] == v2[i]); - } - v.reserve(150); assert(150==v.capacity()); assert(25==v.N()); diff --git a/dune/istl/tutorial/example.cc b/dune/istl/tutorial/example.cc index 020d10ad81acac0ec2628fb0898bac46cb1aa1f2..bd34d12398045e71339ebeeae73a370ae6744f4e 100644 --- a/dune/istl/tutorial/example.cc +++ b/dune/istl/tutorial/example.cc @@ -96,10 +96,6 @@ void test_basearray () Type p[13]; Dune::base_array_window<Type> c(p+4,3); // c contains p[4]...p[6] - // copy window - b = c; - Dune::base_array<Type> d(c); - // move window to p[6]...p[10] c.move(2,5); }