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

Implement assignment of BlockVector from BlockVectorWindow

The implementation for this was hidden in the base classes
before and relied on undefined behaviour by using a downcast.
Now it is explicitly implemented for the derived classes
which also makes it more visible to users.
parent c5e023c5
No related branches found
No related tags found
1 merge request!66Remove forbidden downcast
Pipeline #
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
namespace Dune { namespace Dune {
template<class B, class A=std::allocator<B> >
class BlockVectorWindow;
/** /**
\brief An unmanaged vector of blocks. \brief An unmanaged vector of blocks.
...@@ -574,6 +576,17 @@ namespace Dune { ...@@ -574,6 +576,17 @@ namespace Dune {
(static_cast<block_vector_unmanaged<B,A>&>(*this)) = k; (static_cast<block_vector_unmanaged<B,A>&>(*this)) = k;
return *this; 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: protected:
size_type capacity_; size_type capacity_;
...@@ -624,7 +637,11 @@ namespace Dune { ...@@ -624,7 +637,11 @@ namespace Dune {
Setting the compile time switch DUNE_ISTL_WITH_CHECKING Setting the compile time switch DUNE_ISTL_WITH_CHECKING
enables error checking. enables error checking.
*/ */
#ifndef DOXYGEN
template<class B, class A>
#else
template<class B, class A=std::allocator<B> > template<class B, class A=std::allocator<B> >
#endif
class BlockVectorWindow : public block_vector_unmanaged<B,A> class BlockVectorWindow : public block_vector_unmanaged<B,A>
{ {
public: public:
......
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