diff --git a/dune/istl/basearray.hh b/dune/istl/basearray.hh index 1e1f86f5b58aba19481232644422dbbf12752c62..fd99d1aa7b5aaf89e9b7e9f489dd4c3147b8f75a 100644 --- a/dune/istl/basearray.hh +++ b/dune/istl/basearray.hh @@ -41,13 +41,9 @@ namespace Imp { Setting the compile time switch DUNE_ISTL_WITH_CHECKING enables error checking. - \todo There shouldn't be an allocator argument here, because the array is 'unmanaged'. - And indeed, of the allocator, only its size_type is used. Hence, the signature - of this class should be changed to <class B, int stype> - \internal This class is an implementation detail, and should not be used outside of dune-istl. */ - template<class B, class A=std::allocator<B> > + template<class B, class ST=std::size_t > class base_array_unmanaged { public: @@ -57,11 +53,8 @@ namespace Imp { //! export the type representing the components typedef B member_type; - //! export the allocator type - typedef A allocator_type; - //! the type for the index access - typedef typename A::size_type size_type; + typedef ST size_type; //! the type used for references using reference = B&; @@ -302,7 +295,7 @@ namespace Imp { \internal This class is an implementation detail, and should not be used outside of dune-istl. */ - template<class B, class A=std::allocator<B> > + template<class B, class ST=std::size_t > class compressed_base_array_unmanaged { public: @@ -312,11 +305,8 @@ namespace Imp { //! export the type representing the components typedef B member_type; - //! export the allocator type - typedef A allocator_type; - //! The type used for the index access - typedef typename A::size_type size_type; + typedef ST size_type; //! the type used for references using reference = B&; diff --git a/dune/istl/bcrsmatrix.hh b/dune/istl/bcrsmatrix.hh index 5c480e9819dad9f83fa703d8ceaf3e5104497bad..3806a813b43caaf3fc6903035a72d5420486ad42 100644 --- a/dune/istl/bcrsmatrix.hh +++ b/dune/istl/bcrsmatrix.hh @@ -493,12 +493,12 @@ namespace Dune { //! export the allocator type typedef A allocator_type; - //! implement row_type with compressed vector - typedef Imp::CompressedBlockVectorWindow<B,A> row_type; - //! The type for the index access and the size typedef typename A::size_type size_type; + //! implement row_type with compressed vector + typedef Imp::CompressedBlockVectorWindow<B,size_type> row_type; + //! The type for the statistics object returned by compress() typedef ::Dune::CompressionStatistics<size_type> CompressionStatistics; diff --git a/dune/istl/bvector.hh b/dune/istl/bvector.hh index 6548bd2d4ded6578a63cdcaf6e367b97f7fffad2..28597e59ffc3c485fd1128cb6c9e188939a47b12 100644 --- a/dune/istl/bvector.hh +++ b/dune/istl/bvector.hh @@ -80,8 +80,8 @@ namespace Imp { \internal This class is an implementation detail, and should not be used outside of dune-istl. */ - template<class B, class A=std::allocator<B> > - class block_vector_unmanaged : public base_array_unmanaged<B,A> + template<class B, class ST=std::size_t > + class block_vector_unmanaged : public base_array_unmanaged<B,ST> { public: @@ -91,17 +91,14 @@ namespace Imp { //! export the type representing the components typedef B block_type; - //! export the allocator type - typedef A allocator_type; - //! The size type for the index access - typedef typename A::size_type size_type; + typedef ST size_type; //! make iterators available as types - typedef typename base_array_unmanaged<B,A>::iterator Iterator; + typedef typename base_array_unmanaged<B,ST>::iterator Iterator; //! make iterators available as types - typedef typename base_array_unmanaged<B,A>::const_iterator ConstIterator; + typedef typename base_array_unmanaged<B,ST>::const_iterator ConstIterator; //! for STL compatibility typedef B value_type; @@ -177,8 +174,8 @@ namespace Imp { * @param y other (compatible) vector * @return */ - template<class OtherB, class OtherA> - auto operator* (const block_vector_unmanaged<OtherB,OtherA>& y) const + template<class OtherB, class OtherST> + auto operator* (const block_vector_unmanaged<OtherB,OtherST>& y) const { typedef typename PromotionTraits<field_type,typename BlockTraits<OtherB>::field_type>::PromotedType PromotedType; PromotedType sum(0); @@ -198,8 +195,8 @@ namespace Imp { * @param y other (compatible) vector * @return */ - template<class OtherB, class OtherA> - auto dot(const block_vector_unmanaged<OtherB,OtherA>& y) const + template<class OtherB, class OtherST> + auto dot(const block_vector_unmanaged<OtherB,OtherST>& y) const { typedef typename PromotionTraits<field_type,typename BlockTraits<OtherB>::field_type>::PromotedType PromotedType; PromotedType sum(0); @@ -338,7 +335,7 @@ namespace Imp { protected: //! make constructor protected, so only derived classes can be instantiated - block_vector_unmanaged () : base_array_unmanaged<B,A>() + block_vector_unmanaged () : base_array_unmanaged<B,ST>() { } }; @@ -391,7 +388,7 @@ namespace Imp { enables error checking. */ template<class B, class A=std::allocator<B> > - class BlockVector : public Imp::block_vector_unmanaged<B,A> + class BlockVector : public Imp::block_vector_unmanaged<B,typename A::size_type> { public: @@ -410,10 +407,10 @@ namespace Imp { typedef typename A::size_type size_type; //! make iterators available as types - typedef typename Imp::block_vector_unmanaged<B,A>::Iterator Iterator; + typedef typename Imp::block_vector_unmanaged<B,size_type>::Iterator Iterator; //! make iterators available as types - typedef typename Imp::block_vector_unmanaged<B,A>::ConstIterator ConstIterator; + typedef typename Imp::block_vector_unmanaged<B,size_type>::ConstIterator ConstIterator; //===== constructors and such @@ -552,7 +549,7 @@ namespace Imp { BlockVector& operator= (const field_type& k) { // forward to operator= in base class - (static_cast<Imp::block_vector_unmanaged<B,A>&>(*this)) = k; + (static_cast<Imp::block_vector_unmanaged<B,size_type>&>(*this)) = k; return *this; } @@ -619,7 +616,7 @@ namespace Imp { #else template<class B, class A=std::allocator<B> > #endif - class BlockVectorWindow : public Imp::block_vector_unmanaged<B,A> + class BlockVectorWindow : public Imp::block_vector_unmanaged<B,typename A::size_type> { public: @@ -638,15 +635,15 @@ namespace Imp { typedef typename A::size_type size_type; //! make iterators available as types - typedef typename Imp::block_vector_unmanaged<B,A>::Iterator Iterator; + typedef typename Imp::block_vector_unmanaged<B,size_type>::Iterator Iterator; //! make iterators available as types - typedef typename Imp::block_vector_unmanaged<B,A>::ConstIterator ConstIterator; + typedef typename Imp::block_vector_unmanaged<B,size_type>::ConstIterator ConstIterator; //===== constructors and such //! makes empty array - BlockVectorWindow () : Imp::block_vector_unmanaged<B,A>() + BlockVectorWindow () : Imp::block_vector_unmanaged<B,size_type>() { } //! make array from given pointer and size @@ -682,7 +679,7 @@ namespace Imp { //! assign from scalar BlockVectorWindow& operator= (const field_type& k) { - (static_cast<Imp::block_vector_unmanaged<B,A>&>(*this)) = k; + (static_cast<Imp::block_vector_unmanaged<B,size_type>&>(*this)) = k; return *this; } @@ -741,8 +738,8 @@ namespace Imp { \internal This class is an implementation detail, and should not be used outside of dune-istl. */ - template<class B, class A=std::allocator<B> > - class compressed_block_vector_unmanaged : public compressed_base_array_unmanaged<B,A> + template<class B, class ST=std::size_t > + class compressed_block_vector_unmanaged : public compressed_base_array_unmanaged<B,ST> { public: @@ -754,17 +751,14 @@ namespace Imp { //! export the type representing the components typedef B block_type; - //! export the allocator type - typedef A allocator_type; - //! make iterators available as types - typedef typename compressed_base_array_unmanaged<B,A>::iterator Iterator; + typedef typename compressed_base_array_unmanaged<B,ST>::iterator Iterator; //! make iterators available as types - typedef typename compressed_base_array_unmanaged<B,A>::const_iterator ConstIterator; + typedef typename compressed_base_array_unmanaged<B,ST>::const_iterator ConstIterator; //! The type for the index access - typedef typename A::size_type size_type; + typedef ST size_type; //===== assignment from scalar @@ -961,7 +955,7 @@ namespace Imp { protected: //! make constructor protected, so only derived classes can be instantiated - compressed_block_vector_unmanaged () : compressed_base_array_unmanaged<B,A>() + compressed_block_vector_unmanaged () : compressed_base_array_unmanaged<B,ST>() { } //! return true if index sets coincide @@ -995,8 +989,8 @@ namespace Imp { \internal This class is an implementation detail, and should not be used outside of dune-istl. */ - template<class B, class A=std::allocator<B> > - class CompressedBlockVectorWindow : public compressed_block_vector_unmanaged<B,A> + template<class B, class ST=std::size_t > + class CompressedBlockVectorWindow : public compressed_block_vector_unmanaged<B,ST> { public: @@ -1008,22 +1002,19 @@ namespace Imp { //! export the type representing the components typedef B block_type; - //! export the allocator type - typedef A allocator_type; - //! The type for the index access - typedef typename A::size_type size_type; + typedef ST size_type; //! make iterators available as types - typedef typename compressed_block_vector_unmanaged<B,A>::Iterator Iterator; + typedef typename compressed_block_vector_unmanaged<B,ST>::Iterator Iterator; //! make iterators available as types - typedef typename compressed_block_vector_unmanaged<B,A>::ConstIterator ConstIterator; + typedef typename compressed_block_vector_unmanaged<B,ST>::ConstIterator ConstIterator; //===== constructors and such //! makes empty array - CompressedBlockVectorWindow () : compressed_block_vector_unmanaged<B,A>() + CompressedBlockVectorWindow () : compressed_block_vector_unmanaged<B,ST>() { } //! make array from given pointers and size @@ -1062,7 +1053,7 @@ namespace Imp { //! assign from scalar CompressedBlockVectorWindow& operator= (const field_type& k) { - (static_cast<compressed_block_vector_unmanaged<B,A>&>(*this)) = k; + (static_cast<compressed_block_vector_unmanaged<B,ST>&>(*this)) = k; return *this; } diff --git a/dune/istl/matrix.hh b/dune/istl/matrix.hh index 75d859afa52e765d7c9d2dadbff28e775e795af4..2aff17648313356e96570b53e5b2413be8be50e7 100644 --- a/dune/istl/matrix.hh +++ b/dune/istl/matrix.hh @@ -37,7 +37,7 @@ namespace MatrixImp elegant solution. */ template<class B, class A=std::allocator<B> > - class DenseMatrixBase : public Imp::block_vector_unmanaged<B,A> + class DenseMatrixBase : public Imp::block_vector_unmanaged<B,typename A::size_type> // this derivation gives us all the blas level 1 and norms // on the large array. However, access operators have to be // overwritten. @@ -79,7 +79,7 @@ namespace MatrixImp /** constructor without arguments makes empty vector, object cannot be used yet */ - DenseMatrixBase () : Imp::block_vector_unmanaged<B,A>() + DenseMatrixBase () : Imp::block_vector_unmanaged<B,size_type>() { // nothing is known ... rows_ = 0; @@ -92,7 +92,7 @@ namespace MatrixImp * \param rows Number of rows * \param columns Number of columns */ - DenseMatrixBase (size_type rows, size_type columns) : Imp::block_vector_unmanaged<B,A>() + DenseMatrixBase (size_type rows, size_type columns) : Imp::block_vector_unmanaged<B,size_type>() { // and we can allocate the big array in the base class this->n = rows*columns; @@ -228,7 +228,7 @@ namespace MatrixImp //! assign from scalar DenseMatrixBase& operator= (const field_type& k) { - (static_cast<Imp::block_vector_unmanaged<B,A>&>(*this)) = k; + (static_cast<Imp::block_vector_unmanaged<B,size_type>&>(*this)) = k; return *this; } diff --git a/dune/istl/vbvector.hh b/dune/istl/vbvector.hh index af0750331eed19c53def509cb3847fcd69c6abd1..c5e74732a0e806097c2a202ee641e061a06a35ab 100644 --- a/dune/istl/vbvector.hh +++ b/dune/istl/vbvector.hh @@ -39,7 +39,7 @@ namespace Dune { */ template<class B, class A=std::allocator<B> > - class VariableBlockVector : public Imp::block_vector_unmanaged<B,A> + class VariableBlockVector : public Imp::block_vector_unmanaged<B,typename A::size_type> // this derivation gives us all the blas level 1 and norms // on the large array. However, access operators have to be // overwritten. @@ -88,7 +88,7 @@ namespace Dune { /** constructor without arguments makes empty vector, object cannot be used yet */ - VariableBlockVector () : Imp::block_vector_unmanaged<B,A>() + VariableBlockVector () : Imp::block_vector_unmanaged<B,size_type>() { // nothing is known ... nblocks = 0; @@ -99,7 +99,7 @@ namespace Dune { /** make vector with given number of blocks, but size of each block is not yet known, object cannot be used yet */ - explicit VariableBlockVector (size_type _nblocks) : Imp::block_vector_unmanaged<B,A>() + explicit VariableBlockVector (size_type _nblocks) : Imp::block_vector_unmanaged<B,size_type>() { // we can allocate the windows now nblocks = _nblocks; @@ -125,7 +125,7 @@ namespace Dune { \param _nblocks Number of blocks \param m Number of elements in each block */ - VariableBlockVector (size_type _nblocks, size_type m) : Imp::block_vector_unmanaged<B,A>() + VariableBlockVector (size_type _nblocks, size_type m) : Imp::block_vector_unmanaged<B,size_type>() { // and we can allocate the big array in the base class this->n = _nblocks*m; @@ -389,7 +389,7 @@ namespace Dune { //! assign from scalar VariableBlockVector& operator= (const field_type& k) { - (static_cast<Imp::block_vector_unmanaged<B,A>&>(*this)) = k; + (static_cast<Imp::block_vector_unmanaged<B,size_type>&>(*this)) = k; return *this; } diff --git a/dune/python/istl/bvector.hh b/dune/python/istl/bvector.hh index ee4f5822267f89d75151c244b9afa86624806d0b..2524a1810cb07f4032bf83e5b46e2ba10ce961c2 100644 --- a/dune/python/istl/bvector.hh +++ b/dune/python/istl/bvector.hh @@ -94,7 +94,7 @@ namespace Dune template< class X > inline static auto to_string ( const X &x ) - -> std::enable_if_t< std::is_base_of< Imp::block_vector_unmanaged< typename X::block_type, typename X::allocator_type >, X >::value, std::string > + -> std::enable_if_t< std::is_base_of< Imp::block_vector_unmanaged< typename X::block_type, typename X::size_type >, X >::value, std::string > { return "(" + join( ", ", [] ( auto &&x ) { return to_string( x ); }, x.begin(), x.end() ) + ")"; }