diff --git a/cmake/modules/CheckCXX11Features.cmake b/cmake/modules/CheckCXX11Features.cmake index 91fe8957dfed2989b4e2bf0cbb74a95eba5ba100..8082137ada14102329c9ed89f1f40c4205be8297 100644 --- a/cmake/modules/CheckCXX11Features.cmake +++ b/cmake/modules/CheckCXX11Features.cmake @@ -7,7 +7,6 @@ # HAS_ATTRIBUTE_UNUSED True if attribute unused is supported # HAS_ATTRIBUTE_DEPRECATED True if attribute deprecated is supported # HAS_ATTRIBUTE_DEPRECATED_MSG True if attribute deprecated("msg") is supported -# HAVE_INTEGRAL_CONSTANT True if compiler supports integral_constant # HAVE_CONSTEXPR True if constexpr is supported # HAVE_KEYWORD_FINAL True if final is supported. @@ -60,53 +59,6 @@ check_cxx_source_compiles(" } " HAVE_NULLPTR ) -include(CheckIncludeFile) -include(CheckIncludeFileCXX) - -if(NOT DISABLE_TR1_HEADERS) -# Search for some tr1 headers -foreach(_HEADER type_traits tr1/type_traits) - string(REPLACE "/" "_" _HEADER_VAR ${_HEADER}) - string(TOUPPER ${_HEADER_VAR} _HEADER_VAR ) - check_include_file_cxx(${_HEADER} "HAVE_${_HEADER_VAR}") -endforeach() - -# Check for hash support -check_include_file_cxx("functional" "HAVE_FUNCTIONAL") -if(NOT HAVE_FUNCTIONAL) - check_include_file_cxx("tr1/functional" "HAVE_TR1_FUNCTIONAL") - if(HAVE_TR1_FUNCTIONAL) - set(_functional_header "tr1/functional") - set(_hash_type "std::tr1::hash") - set(_hash_variable "HAVE_TR1_HASH") - endif(HAVE_TR1_FUNCTIONAL) -else() - set(_functional_header "functional") - set(_hash_type "std::hash") - set(_hash_variable "HAVE_STD_HASH") -endif(NOT HAVE_FUNCTIONAL) - -if(_functional_header) - check_cxx_source_compiles(" - #include <${_functional_header}> - int main(void){ - ${_hash_type}<int> hasher; hasher(42); - } -" ${_hash_variable}) -endif(_functional_header) - -# Check whether if std::integral_constant< T, v > is supported and casts into T -check_cxx_source_compiles(" - #include <type_traits> - void f( int ){} - - int main(void){ - f( std::integral_constant< int, 42 >() ); - } -" HAVE_INTEGRAL_CONSTANT -) - -endif(NOT DISABLE_TR1_HEADERS) # __attribute__((unused)) check_cxx_source_compiles(" diff --git a/config.h.cmake b/config.h.cmake index baafeaf47dc107bb8a0bc0561a2d5462b863e598..78bae4b369fcaded288a95ec46e685fc95677ab3 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -29,6 +29,10 @@ /* old feature support macros which were tested until 2.3, keep around for one more release */ /* As these are now always supported due to the new compiler requirements, they are directly */ /* defined without an explicit test. */ +#define HAVE_INTEGRAL_CONSTANT 1 +#define HAVE_DUNE_HASH 1 +#define HAVE_STD_HASH 1 +#define HAVE_TYPE_TRAITS 1 #define HAVE_VARIADIC_TEMPLATES 1 #define HAVE_VARIADIC_CONSTRUCTOR_SFINAE 1 #define HAVE_RVALUE_REFERENCES 1 @@ -69,23 +73,6 @@ /* Define to 1 if you have <sys/mman.h>. */ #cmakedefine HAVE_SYS_MMAN_H 1 -/* Define to 1 if the std::tr1::hash template from TR1 is available. */ -#cmakedefine HAVE_TR1_HASH 1 - -/* Define to 1 if you have the <tr1/type_traits> header file. */ -#cmakedefine HAVE_TR1_TYPE_TRAITS 1 - -/* Define to 1 if std::integral_constant< T, v > is supported - * and casts into T - */ -#cmakedefine HAVE_INTEGRAL_CONSTANT 1 - -/* Define to 1 if the std::hash template from C++11 is available. */ -#cmakedefine HAVE_STD_HASH 1 - -/* Define to 1 if you have the <type_traits> header file. */ -#cmakedefine HAVE_TYPE_TRAITS 1 - /* Define to 1 if the MPI2 Standard is supported */ #cmakedefine MPI_2 1 diff --git a/dune/common/alignment.hh b/dune/common/alignment.hh index f978f57ff37851725aacbda57f4482691e287a2b..0d8c5e92d114a14e4ba9d1337ce95bdfe526aeb1 100644 --- a/dune/common/alignment.hh +++ b/dune/common/alignment.hh @@ -3,12 +3,9 @@ // $Id$ #ifndef DUNE_ALIGNMENT_HH #define DUNE_ALIGNMENT_HH + #include <cstddef> -#if HAVE_TYPE_TRAITS #include <type_traits> -#elif HAVE_TR1_TYPE_TRAITS -#include <tr1/type_traits> -#endif namespace Dune { @@ -102,13 +99,7 @@ namespace Dune enum { /** @brief The alignment requirement. */ -#ifdef HAVE_TYPE_TRAITS value = std::alignment_of<T>::value -#elif HAVE_TR1_TYPETRAITS - value = std::tr1::alignment_of<T>::value -#else - value = AlignmentTester<T, sizeof(AlignmentStruct<T>) - sizeof(T) -1>::result -#endif }; }; diff --git a/dune/common/bigunsignedint.hh b/dune/common/bigunsignedint.hh index 18e7d7d24eb0157861e70309838ed3c927578cf1..2c57c029a32dbf4ed7642609f7e2aedda14b3fdb 100644 --- a/dune/common/bigunsignedint.hh +++ b/dune/common/bigunsignedint.hh @@ -134,15 +134,11 @@ namespace Dune friend class bigunsignedint<k/2>; friend struct std::numeric_limits< bigunsignedint<k> >; -#if HAVE_DUNE_HASH - inline friend std::size_t hash_value(const bigunsignedint& arg) { return hash_range(arg.digit,arg.digit + arg.n); } -#endif // HAVE_DUNE_HASH - private: unsigned short digit[n]; #if HAVE_MPI diff --git a/dune/common/hash.hh b/dune/common/hash.hh index a0468d1f894d062bf6690dc0226a156456c8d6cd..be887027a60ad128bbfa90665a8245e6d5907ff5 100644 --- a/dune/common/hash.hh +++ b/dune/common/hash.hh @@ -3,32 +3,9 @@ #ifndef DUNE_COMMON_HASH_HH #define DUNE_COMMON_HASH_HH -#include <dune/common/typetraits.hh> - -#if HAVE_STD_HASH #include <functional> -#endif - -#if HAVE_TR1_HASH -#include <tr1/functional> -#endif - -#if HAVE_DUNE_BOOST - -#include <boost/version.hpp> -// Boost 1.34.0 seems to be the first usable version of boost::functional::hash -#if BOOST_VERSION >= 103400 -#define HAVE_BOOST_HASH 1 - -// only pull in boost if really necessary -#if !HAVE_STD_HASH && !HAVE_TR1_HASH - -#include <boost/functional/hash.hpp> - -#endif // !HAVE_STD_HASH && !HAVE_TR1_HASH -#endif // BOOST_VERSION >= 103400 -#endif // HAVE_DUNE_BOOST +#include <dune/common/typetraits.hh> /** * \file @@ -55,10 +32,6 @@ namespace Dune { * The interface outlined below is compatible with std::hash, std::tr1::hash and * boost::hash, so it is possible to use Dune::hash in associative containers from * those libraries. - * - * The current implementation piggybacks on top of C++11, TR1 or Boost, in that order. - * As there is no local fallback implementation, hashing will not work without at least - * one of those dependencies installed. */ template<typename T> struct hash @@ -149,12 +122,6 @@ namespace Dune { // C++11 support // ******************************************************************************** -#if HAVE_STD_HASH -// We have std::hash from C++11 - -// Announce that we provide Dune::hash -#define HAVE_DUNE_HASH 1 - // import std::hash into Dune namespace namespace Dune { @@ -179,70 +146,6 @@ namespace Dune { \ } \ -#else // HAVE_STD_HASH - -// We do not support std::hash, so don't do anything here. -#define DUNE_DEFINE_STD_HASH(template_args,type) - -#endif // HAVE_STD_HASH - - - -// ******************************************************************************** -// TR1 support -// ******************************************************************************** - -#if HAVE_TR1_HASH -// We have std::tr1::hash from TR1 - -#ifndef HAVE_DUNE_HASH -// std::hash wasn't found, so use std::tr1::hash - -// Announce that we provide Dune::hash -#define HAVE_DUNE_HASH 1 - -// import std::tr1::hash into Dune namespace -namespace Dune { - - using std::tr1::hash; - -} - -#endif // HAVE_DUNE_HASH - -// Macro for defining a std::tr1::hash specialization for type. -// This should not be called directly. Call DUNE_DEFINE_HASH -// instead. -#define DUNE_DEFINE_TR1_HASH(template_args,type) \ - namespace std { \ - namespace tr1 { \ - \ - template<template_args> \ - struct hash<type> \ - { \ - std::size_t operator()(const type& arg) const \ - { \ - return hash_value(arg); \ - } \ - }; \ - \ - } \ - } \ - -#else // HAVE_TR1_HASH - -// We do not support std::tr1::hash, so don't do anything here. -#define DUNE_DEFINE_TR1_HASH(template_args,type) - -#endif // HAVE_TR1_HASH - - - -// ******************************************************************************** -// common macros for both C++11 and TR1 support -// ******************************************************************************** - -#if HAVE_STD_HASH || HAVE_TR1_HASH // Wrapper macro for template arguments. // This is required because the template arguments can contain commas, @@ -267,50 +170,7 @@ namespace Dune { // Define specializations for all discovered hash implementations. #define DUNE_DEFINE_HASH(template_args,type) \ DUNE_DEFINE_STD_HASH(DUNE_HASH_EXPAND_VA_ARGS template_args, DUNE_HASH_EXPAND_VA_ARGS type) \ - DUNE_DEFINE_TR1_HASH(DUNE_HASH_EXPAND_VA_ARGS template_args,DUNE_HASH_EXPAND_VA_ARGS type) \ - - -#else // HAVE_STD_HASH || HAVE_TR1_HASH - - -// Fallback implementation that doesn't do anything. -#define DUNE_DEFINE_HASH(template_args,type) - -// Consider DUNE_HASH_TEMPLATE_ARGS as an argument-less macro and -// replace it with an empty token. -// This will leave its arguments in parentheses, causing them -// to be considered as a single argument to DUNE_DEFINE_HASH, which -// will ignore them anyway. -#define DUNE_HASH_TEMPLATE_ARGS - -// Replace DUNE_HASH_TYPE with an empty token. See above for rationale. -#define DUNE_HASH_TYPE -#endif // HAVE_STD_HASH || HAVE_TR1_HASH - - - -// ******************************************************************************** -// Boost support -// ******************************************************************************** - -#if !HAVE_DUNE_HASH && HAVE_BOOST_HASH -// We haven't found a hash implementation yet and Boost is available - -// Announce that we provide Dune::hash -#define HAVE_DUNE_HASH 1 - -// import boost::hash into Dune namespace -namespace Dune { - - using boost::hash; - -} - -// We no not need to register our types with boost::hash, as its extension -// mechanism will automatically pick up the global hash_value() functions. - -#endif // !HAVE_DUNE_HASH && HAVE_BOOST_HASH #endif // DOXYGEN @@ -320,8 +180,6 @@ namespace Dune { // Some utility functions for combining hashes of member variables. // ******************************************************************************** -#if HAVE_DUNE_HASH || defined(DOXYGEN) - namespace Dune { // The following functions are an implementation of the proposed hash extensions for @@ -475,6 +333,4 @@ namespace Dune { } // end namespace Dune -#endif // HAVE_DUNE_HASH || defined(DOXYGEN) - #endif // DUNE_COMMON_HASH_HH diff --git a/dune/common/typetraits.hh b/dune/common/typetraits.hh index 9bc357edd7cc7cb6d710d00dda5cc62d9999e499..fb0c0e6ab6bf425c307489df40c2da4a7ac6e50d 100644 --- a/dune/common/typetraits.hh +++ b/dune/common/typetraits.hh @@ -3,11 +3,7 @@ #ifndef DUNE_TYPETRAITS_HH #define DUNE_TYPETRAITS_HH -#if defined HAVE_TYPE_TRAITS #include <type_traits> -#elif defined HAVE_TR1_TYPE_TRAITS -#include <tr1/type_traits> -#endif #include <dune/common/deprecated.hh> @@ -163,41 +159,8 @@ namespace Dune typedef volatile typename ConstantVolatileTraits<T>::UnqualifiedType Type; }; -#if defined HAVE_TYPE_TRAITS using std::remove_const; -#elif defined HAVE_TR1_TYPE_TRAITS - using std::tr1::remove_const; -#else - /** - * @brief Removes a const qualifier while preserving others. - */ - template<typename T> - struct remove_const - { - typedef typename RemoveConstHelper<T, IsVolatile<T>::value>::Type type; - }; -#endif - -#if defined HAVE_TYPE_TRAITS using std::remove_reference; -#elif defined HAVE_TR1_TYPE_TRAITS - using std::tr1::remove_reference; -#else - //! Remove a reference from a type - /** - * If the template parameter \c T matches \c T1&, then the member typedef \c - * type is \c T1, otherwise it is \c T. - */ - template<typename T> struct remove_reference { - //! T with references removed - typedef T type; - }; -# ifndef DOXYGEN - template<typename T> struct remove_reference<T&> { - typedef T type; - }; -# endif // ! defined(DOXYGEN) -#endif /** * @brief Checks wether a type is convertible to another. @@ -315,26 +278,7 @@ namespace Dune }; }; -#ifdef HAVE_TYPE_TRAITS using std::enable_if; -#else - /** - * @brief Enable typedef if condition is met. - * - * Replacement implementation for compilers without this in the stl. - * Depending on the value of b the type T is provided as typedef type. - */ - template<bool b, typename T=void> - struct enable_if - { - typedef T type; - }; - - template<typename T> - struct enable_if<false,T> - {}; -#endif - /** * @brief Enable typedef if two types are interoperable. @@ -346,67 +290,13 @@ namespace Dune : public enable_if<IsInteroperable<T1,T2>::value, Type> {}; -#if defined HAVE_TYPE_TRAITS - using std::is_same; -#elif defined HAVE_TR1_TYPE_TRAITS - using std::tr1::is_same; -#else - /** - * @brief Compile time test for testing whether - * two types are the same. - */ - template<typename T1, typename T2> - struct is_same - { - //! Whether T1 is the same type as T2. - enum { - /* @brief Whether T1 is the same type as T2. */ - value=false - }; - }; - - - template<typename T> - struct is_same<T,T> - { - enum { value=true}; - }; -#endif - // pull in default implementation + using std::is_same; using std::conditional; - - //////////////////////////////////////////////////////////////////////// - // - // integral_constant (C++0x 20.7.3 "Helper classes") - // -#if HAVE_INTEGRAL_CONSTANT using std::integral_constant; using std::true_type; using std::false_type; -#else // #if HAVE_INTEGRAL_CONSTANT - //! Generate a type for a given integral constant - /** - * \tparam T Type of the constant. - * \tparam v Value of the constant. - */ - template <class T, T v> - struct integral_constant { - //! value this type was generated for - static const T value = v; - //! type of value - typedef T value_type; - //! type of this class itself - typedef integral_constant<T,v> type; - //! conversion to value_type/T - operator value_type() { return value; } - }; - //! type for true - typedef integral_constant<bool, true> true_type; - //! type for false - typedef integral_constant<bool, false> false_type; -#endif // #else // #if HAVE_INTEGRAL_CONSTANT template<typename> struct __is_pointer_helper diff --git a/m4/CMakeLists.txt b/m4/CMakeLists.txt index 0819a7f1407a76cf5504d8e36a00cd5da75ebace..1de8462b8ef97a6f7698d36135785b0aff236d0a 100644 --- a/m4/CMakeLists.txt +++ b/m4/CMakeLists.txt @@ -25,7 +25,6 @@ install(PROGRAMS dune_linkcxx.m4 dune_mpi.m4 dune_streams.m4 - dune_tr1_headers.m4 dune_unused.m4 fortran_overwrite.m4 gmp.m4 diff --git a/m4/Makefile.am b/m4/Makefile.am index 72c4e7c2afb585d8843c93e4455795f957393a3a..fddde4a672ed8ba465fee1dd27a652c45b4d6502 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -28,7 +28,6 @@ ALLM4S = \ dune_linkcxx.m4 \ dune_mpi.m4 \ dune_streams.m4 \ - dune_tr1_headers.m4 \ dune_unused.m4 \ fortran_overwrite.m4 \ gmp.m4 \ diff --git a/m4/cxx11_compiler.m4 b/m4/cxx11_compiler.m4 index 0f73923889e1fe68190c567684af32f4d200b738..2762c11de5ba981739030d9401e5132b0b84919f 100644 --- a/m4/cxx11_compiler.m4 +++ b/m4/cxx11_compiler.m4 @@ -65,6 +65,10 @@ AC_DEFUN([CXX11],[ fi # set feature support macros for backwards compatibility + AC_DEFINE(HAVE_INTEGRAL_CONSTANT, 1, [THIS MACRO IS DEPRECATED AND ONLY KEPT FOR BACKWARDS COMPATIBILITY UNTIL THE NEXT RELEASE!]) + AC_DEFINE(HAVE_DUNE_HASH, 1, [THIS MACRO IS DEPRECATED AND ONLY KEPT FOR BACKWARDS COMPATIBILITY UNTIL THE NEXT RELEASE!]) + AC_DEFINE(HAVE_STD_HASH, 1, [THIS MACRO IS DEPRECATED AND ONLY KEPT FOR BACKWARDS COMPATIBILITY UNTIL THE NEXT RELEASE!]) + AC_DEFINE(HAVE_TYPE_TRAITS, 1, [THIS MACRO IS DEPRECATED AND ONLY KEPT FOR BACKWARDS COMPATIBILITY UNTIL THE NEXT RELEASE!]) AC_DEFINE(HAVE_VARIADIC_TEMPLATES, 1, [THIS MACRO IS DEPRECATED AND ONLY KEPT FOR BACKWARDS COMPATIBILITY UNTIL THE NEXT RELEASE!]) AC_DEFINE(HAVE_VARIADIC_CONSTRUCTOR_SFINAE, 1, [THIS MACRO IS DEPRECATED AND ONLY KEPT FOR BACKWARDS COMPATIBILITY UNTIL THE NEXT RELEASE!]) AC_DEFINE(HAVE_RVALUE_REFERENCES, 1, [THIS MACRO IS DEPRECATED AND ONLY KEPT FOR BACKWARDS COMPATIBILITY UNTIL THE NEXT RELEASE!]) diff --git a/m4/dune_common.m4 b/m4/dune_common.m4 index 7949a805a071ad6e1077539e7b386b91a3bc0fa8..2b8703d47cf38799d83eda7bbf161a1c95935327 100644 --- a/m4/dune_common.m4 +++ b/m4/dune_common.m4 @@ -31,7 +31,6 @@ AC_DEFUN([DUNE_COMMON_CHECKS], AC_REQUIRE([DUNE_PATH_XDR]) AC_REQUIRE([DUNE_MPI]) AC_REQUIRE([DUNE_SYS_MPROTECT]) - AC_REQUIRE([DUNE_TR1_HEADERS]) dnl check for programs AC_REQUIRE([AC_PROG_CC]) diff --git a/m4/dune_tr1_headers.m4 b/m4/dune_tr1_headers.m4 deleted file mode 100644 index 559e94b6b598ed03bfd295606d46401c7fb3caf7..0000000000000000000000000000000000000000 --- a/m4/dune_tr1_headers.m4 +++ /dev/null @@ -1,52 +0,0 @@ -## -*- autoconf -*- -AC_DEFUN([DUNE_TR1_HEADERS], [ - # Allow disabling tr1 headers. E.g. needed for broken xlc on Blue Gene - AC_LANG_PUSH([C++]) - AC_ARG_ENABLE([tr1-headers], - [AS_HELP_STRING([--disable-tr1-headers], - [Prevents checking for tr1 headers like tuple, array, etc. - This might be needed for broken compilers like xlc on Blue Gene])], - [], - [enable_tr1_headers=yes]) - AS_IF([test "x$enable_tr1_headers" != "xno"], - [AC_CHECK_HEADERS([type_traits tr1/type_traits]) - AC_CACHE_CHECK([whether integral_constant conforming to C++11 is supported], dune_cv_integral_constant_cplusplus11, [ - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ - #include <type_traits> - void f( int ); - ],[ - f( std::integral_constant< int, 42 >() ); - ]) - ],[ - dune_cv_integral_constant_cplusplus11=yes - ],[ - dune_cv_integral_constant_cplusplus11=no - ]) - ]) - AS_IF([test "x$dune_cv_integral_constant_cplusplus11" != "xno"],[ - AC_DEFINE([HAVE_INTEGRAL_CONSTANT], 1, [Define to 1 if std::integral_constant< T, v > is supported and casts into T]) - ]) - AC_CACHE_CHECK([whether std::hash from C++11 is supported], dune_cv_hash_cplusplus11, [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include <functional>]], - [[std::hash<int> hasher; hasher(42);]])], - dune_cv_hash_cplusplus11=yes, - dune_cv_hash_cplusplus11=no) - ]) - AS_IF([test "x$dune_cv_hash_cplusplus11" != "xno"], - [AC_DEFINE([HAVE_STD_HASH], 1, [Define to 1 if the std::hash template from C++11 is available]) - ]) - AC_CACHE_CHECK([whether std::tr1::hash from TR1 is supported], dune_cv_hash_cplusplustr1, [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include <tr1/functional>]], - [[std::tr1::hash<int> hasher; hasher(42);]])], - dune_cv_hash_cplusplustr1=yes, - dune_cv_hash_cplusplustr1=no) - ]) - AS_IF([test "x$dune_cv_hash_cplusplustr1" != "xno"], - [AC_DEFINE([HAVE_TR1_HASH], 1, [Define to 1 if the std::tr1::hash template from TR1 is available]) - ]) - ]) - AC_LANG_POP([C++]) -])