From 69fdd82f52d2098eb15bef6c06ab57be63839fec Mon Sep 17 00:00:00 2001 From: Christian Engwer <christi@dune-project.org> Date: Sat, 23 Oct 2010 10:30:02 +0000 Subject: [PATCH] the size of std::array is stored as size_t, we now do the same for Dune::array [[Imported from SVN: r6200]] --- dune/common/array.hh | 19 ++++++++++--------- dune/common/parametertree.hh | 14 -------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/dune/common/array.hh b/dune/common/array.hh index 7ee963781..e475f80fa 100644 --- a/dune/common/array.hh +++ b/dune/common/array.hh @@ -35,7 +35,7 @@ namespace Dune * if that is not available. * */ - template<class T, int N> + template<class T, size_t N> class array { public: @@ -72,7 +72,7 @@ namespace Dune //! Assign value to all entries array<T,N>& operator= (const T& t) { - for (int i=0; i<N; i++) a[i]=t; + for (size_type i=0; i<N; i++) a[i]=t; return (*this); } @@ -85,7 +85,7 @@ namespace Dune //! \brief Assign value to all entries (according to C++0x the fill method is to be prefered) void fill(const T& t) { - for (int i=0; i<N; i++) a[i]=t; + for (size_type i=0; i<N; i++) a[i]=t; } //! Component access @@ -128,36 +128,37 @@ namespace Dune // Comparison Operators (see [lib.container.requirements]) // ------------------------------------------------------- - template< class T, int N > + template< class T, size_t N > inline bool operator< ( const array< T, N > &a, const array< T, N > &b ) { return std::lexicographical_compare( a.begin(), a.end(), b.begin(), b.end() ); } - template< class T, int N > + template< class T, size_t N > inline bool operator> ( const array< T, N > &a, const array< T, N > &b ) { return b < a; } - template< class T, int N > + template< class T, size_t N > inline bool operator<= ( const array< T, N > &a, const array< T, N > &b ) { return !(a > b); } - template< class T, int N > + template< class T, size_t N > inline bool operator>= ( const array< T, N > &a, const array< T, N > &b ) { return !(a < b); } #endif + //! Output operator for array - template <class T, int N> + template < class T, size_t N > inline std::ostream& operator<< (std::ostream& s, const array<T,N>& e) { s << "["; - for (int i=0; i<N-1; i++) s << e[i] << ","; + for (size_t i=0; i<N-1; i++) s << e[i] << ","; s << e[N-1] << "]"; return s; } diff --git a/dune/common/parametertree.hh b/dune/common/parametertree.hh index d4917a13f..f16a468bd 100644 --- a/dune/common/parametertree.hh +++ b/dune/common/parametertree.hh @@ -315,20 +315,6 @@ namespace Dune { } }; - // Yes, there are two specializations for array. This one is for the Dune - // implementation, which takes the size as an int. - template<typename T, int n> - struct ParameterTree::Parser<array<T, n> > { - static array<T, n> - parse(const std::string& str) { - array<T, n> val; - parseRange(str, val.begin(), val.end()); - return val; - } - }; - - // Yes, there are two specializations for array. This one is for the - // implementation from the standard, which takes the size as a size_t. template<typename T, std::size_t n> struct ParameterTree::Parser<array<T, n> > { static array<T, n> -- GitLab