Skip to content
Snippets Groups Projects
Commit f5cdbd5d authored by Oliver Sander's avatar Oliver Sander
Browse files

I am reapplying patch 4933 (use of stl implementation of std::array, if available).

The segfault I reported remains extremely elusive, I have not been able to reliably
reproduce it, let alone track iit down.  On the other hand, my production codes runs 
smoothly with this patch.

Also, FixedArray is deprecated now.


[[Imported from SVN: r4949]]
parent 03561329
No related branches found
No related tags found
No related merge requests found
......@@ -3,17 +3,24 @@
#ifndef DUNE_FIXEDARRAY_HH
#define DUNE_FIXEDARRAY_HH
//***********************************************************************
//
// implementation of peter array
//
//***********************************************************************
/** \file
\brief implementation of the stl array class (a static array)
and its deprecated ancestor FixedArray
*/
#include <iostream>
#include <iomanip>
#include <string>
// Include system implementation of array class if present
#ifdef HAVE_ARRAY
#include <array>
#endif
#ifdef HAVE_TR1_ARRAY
#include <tr1/array>
#endif
namespace Dune
{
/** @addtogroup Common
......@@ -21,6 +28,12 @@ namespace Dune
@{
*/
#ifdef HAVE_ARRAY
using std::array;
#elif defined HAVE_TR1_ARRAY
using std::tr1::array;
#else
/** \brief Simple fixed size array class
*
*/
......@@ -58,8 +71,10 @@ namespace Dune
//! Create uninitialized array
array () {}
//! Initialize all components with same size
array (const T& t)
/** \brief Initialize all components with same entry
\deprecated Deprecated because the stl implementation of array doesn't have it
*/
array (const T& t) DUNE_DEPRECATED
{
for (int i=0; i<N; i++) a[i]=t;
}
......@@ -89,7 +104,7 @@ namespace Dune
protected:
T a[(N > 0) ? N : 1];
};
#endif
//! Output operator for array
template <class T, int N>
inline std::ostream& operator<< (std::ostream& s, array<T,N> e)
......@@ -118,17 +133,14 @@ namespace Dune
enum { dimension = N };
//! Create uninitialized array
FixedArray () {}
FixedArray () DUNE_DEPRECATED {}
//! Initialize all components with same size
FixedArray (T t)
FixedArray (T t) DUNE_DEPRECATED
{
for (int i=0; i<N; i++) a[i]=t;
}
/** \brief Return array size */
int size() const {return N;}
//! Assign value to all entries
FixedArray<T,N>& operator= (const T& t)
{
......@@ -169,7 +181,7 @@ namespace Dune
protected:
T a[n];
};
} DUNE_DEPRECATED;
//! Output operator for FixedArray
template <class T, int N>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment