Skip to content
Snippets Groups Projects
Commit 69fdd82f authored by Christian Engwer's avatar Christian Engwer
Browse files

the size of std::array is stored as size_t, we now do the same for Dune::array

[[Imported from SVN: r6200]]
parent ff2db99e
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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>
......
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