Skip to content
Snippets Groups Projects
Commit 3a38782f authored by Christoph Grüninger's avatar Christoph Grüninger
Browse files

[cleanup] Remove check and fallback code for std::array.

parent 7bb2bdbb
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@
# Sets the follwing variables:
#
# HAVE_NULLPTR True if nullptr is available
# HAVE_ARRAY True if header <array> and fill() are available
# HAVE_ATTRIBUTE_ALWAYS_INLINE True if attribute always inline is supported
# HAS_ATTRIBUTE_UNUSED True if attribute unused is supported
# HAS_ATTRIBUTE_DEPRECATED True if attribute deprecated is supported
......@@ -66,19 +65,6 @@ include(CheckIncludeFile)
include(CheckIncludeFileCXX)
if(NOT DISABLE_TR1_HEADERS)
# array and fill
check_cxx_source_compiles("
#include <array>
int main(void)
{
std::array<int,2> a;
a.fill(9);
return 0;
}
" HAVE_ARRAY
)
# Search for some tr1 headers
foreach(_HEADER tuple tr1/tuple type_traits tr1/type_traits)
string(REPLACE "/" "_" _HEADER_VAR ${_HEADER})
......
......@@ -34,9 +34,6 @@
/* does the compiler support __attribute__((unused))? */
#cmakedefine HAS_ATTRIBUTE_UNUSED 1
/* Define to 1 if the header <array> from C++11 is available and supports array::fill */
#cmakedefine HAVE_ARRAY 1
/* Define if you have a BLAS library. */
#cmakedefine HAVE_BLAS 1
......
......@@ -1100,12 +1100,13 @@ available and which dimension has been selected (if applicable). This
information can then be used at compile-time to include header files
or code that depend on optional packages.
As an example, the macro \lstinline!HAVE_ARRAY!\ can be used to compile
code using C++11 arrays as in
As an example, the macro \lstinline!HAVE_GMP!\ can be used to compile
code using the GNU Multiple Precision Arithmetic Library (GMP) as in
\begin{lstlisting}[basicstyle=\ttfamily\scriptsize]
#ifdef HAVE_ARRAY
#include <array>
std::array <int, 5> a = {1, 2, 3};
#ifdef HAVE_GMP
#include <gmp.h>
mpz_t d;
mpz_init_set_str(d, "14159265", 10);
#endif
\end{lstlisting}
......
......@@ -8,18 +8,8 @@
\brief Fallback implementation of the std::array class (a static array)
*/
#include <iostream>
#include <iomanip>
#include <string>
// Include system implementation of array class if present
#ifdef HAVE_ARRAY
#include <array>
#else
#include <algorithm>
#endif
#include "deprecated.hh"
namespace Dune
{
......@@ -28,131 +18,8 @@ namespace Dune
@{
*/
#ifdef HAVE_ARRAY
// pull in default implementation
using std::array;
#else
/** \brief Simple fixed size array class. This replaces std::array,
* if that is not available.
*
*/
template<class T, size_t N>
class array {
public:
//! Remember the storage type
typedef T value_type;
/** \brief Reference to an object */
typedef value_type& reference;
/** \brief Const reference to an object */
typedef const value_type& const_reference;
/** \brief Iterator type */
typedef value_type* iterator;
/** \brief Const iterator type */
typedef const value_type* const_iterator;
/** \brief Type used for array indices */
typedef std::size_t size_type;
/** \brief Difference type */
typedef std::ptrdiff_t difference_type;
/** \brief Reverse iterator type */
typedef std::reverse_iterator<iterator> reverse_iterator;
/** \brief Const reverse iterator type */
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
/** \brief Return array size */
size_type size() const {return N;}
//! Assign value to all entries
array<T,N>& operator= (const T& t)
{
fill(t);
return (*this);
}
//! \brief Assign value to all entries (according to C++0x the fill method is to be prefered)
void assign(const T& t) DUNE_DEPRECATED
{
fill(t);
}
//! \brief Assign value to all entries (according to C++0x the fill method is to be prefered)
void fill(const T& t)
{
for (size_type i=0; i<N; i++) a[i]=t;
}
//! Component access
reference operator[] (size_type i)
{
return a[i];
}
//! Const component access
const_reference operator[] (size_type i) const
{
return a[i];
}
iterator begin ()
{
return a;
}
const_iterator begin () const
{
return a;
}
iterator end ()
{
return a + N;
}
const_iterator end () const
{
return a + N;
}
T a[(N > 0) ? N : 1];
};
// Comparison Operators (see [lib.container.requirements])
// -------------------------------------------------------
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, size_t N >
inline bool operator> ( const array< T, N > &a, const array< T, N > &b )
{
return b < a;
}
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, 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, size_t N >
......
......@@ -10,16 +10,6 @@ AC_DEFUN([DUNE_TR1_HEADERS], [
[enable_tr1_headers=yes])
AS_IF([test "x$enable_tr1_headers" != "xno"],
[AC_CHECK_HEADERS([type_traits tr1/type_traits tuple tr1/tuple])
AC_CACHE_CHECK([whether <array> C++0x is supported], dune_cv_array_cplusplus0x, [
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <array>]],
[[std::array<int,2> a; a.fill(9);]])],
dune_cv_array_cplusplus0x=yes,
dune_cv_array_cplusplus0x=no)
])
AS_IF([test "x$dune_cv_array_cplusplus0x" != "xno"],
[AC_DEFINE([HAVE_ARRAY], 1, [Define to 1 if the header <array> from C++0x is available and supports array::fill])
])
AC_CACHE_CHECK([whether integral_constant conforming to C++11 is supported], dune_cv_integral_constant_cplusplus11, [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
......
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