From 03adc7570c459924296a82b0108ae6d204339209 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= <gruenich@dune-project.org>
Date: Sat, 22 Mar 2014 15:31:11 +0100
Subject: [PATCH] [cleanup] Remove check for rvalue references.

---
 cmake/modules/CheckCXX11Features.cmake | 23 ------------------
 config.h.cmake                         |  3 ---
 dune/common/array.hh                   |  4 ----
 dune/common/debugallocator.hh          |  4 ++--
 dune/common/mallocallocator.hh         |  4 ++--
 dune/common/test/typetraitstest.cc     |  6 -----
 m4/CMakeLists.txt                      |  1 -
 m4/Makefile.am                         |  1 -
 m4/cxx0x_rvaluereference.m4            | 32 --------------------------
 m4/dune_common.m4                      |  1 -
 10 files changed, 4 insertions(+), 75 deletions(-)
 delete mode 100644 m4/cxx0x_rvaluereference.m4

diff --git a/cmake/modules/CheckCXX11Features.cmake b/cmake/modules/CheckCXX11Features.cmake
index 9f3cd9ecb..19cbcaf6f 100644
--- a/cmake/modules/CheckCXX11Features.cmake
+++ b/cmake/modules/CheckCXX11Features.cmake
@@ -9,7 +9,6 @@
 # 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_RVALUE_REFERENCES           True if rvalue references are supported
 # HAVE_CONSTEXPR                   True if constexpr is supported
 # HAVE_KEYWORD_FINAL               True if final is supported.
 
@@ -181,28 +180,6 @@ check_cxx_source_compiles("
 "  HAS_ATTRIBUTE_DEPRECATED_MSG
 )
 
-# rvalue references
-check_cxx_source_compiles("
-  #include <cassert>
-  #include <utility>
-  int foo(int&& x) { return 1; }
-  int foo(const int& x) { return -1; }
-
-  template<typename T>
-  int forward(T&& x)
-  {
-    return foo(std::forward<T>(x));
-  }
-
-  int main(void)
-  {
-    int i = 0;
-    assert( forward(i) + forward(int(2)) == 0);
-    return 0;
-  }
-" HAVE_RVALUE_REFERENCES
-)
-
 # constexpr
 check_cxx_source_compiles("
   constexpr int foo()
diff --git a/config.h.cmake b/config.h.cmake
index 4b508260a..7cc419b9d 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -124,9 +124,6 @@
 
 /* end private */
 
-/* Define to 1 if rvalue references are supported */
-#cmakedefine HAVE_RVALUE_REFERENCES 1
-
 /* Define to 1 if C++11 constexpr is supported */
 #cmakedefine HAVE_CONSTEXPR 1
 
diff --git a/dune/common/array.hh b/dune/common/array.hh
index 05a251d9f..fea925d40 100644
--- a/dune/common/array.hh
+++ b/dune/common/array.hh
@@ -129,11 +129,7 @@ namespace Dune
   {
     array<T,n> r;
     r.fill(t);
-#if HAVE_RVALUE_REFERENCES
     return std::move(r);
-#else
-    return r;
-#endif
   }
 
   /** @} */
diff --git a/dune/common/debugallocator.hh b/dune/common/debugallocator.hh
index 1327a2996..db5c0a40b 100644
--- a/dune/common/debugallocator.hh
+++ b/dune/common/debugallocator.hh
@@ -277,14 +277,14 @@ namespace Dune
     {
       ::new((void*)p)T(val);
     }
-#if HAVE_RVALUE_REFERENCES || DOXYGEN
+
     //! construct an object of type T from variadic parameters
     template<typename ... _Args>
     void construct(pointer p, _Args&&... __args)
     {
       ::new((void *)p)T(std::forward<_Args>(__args) ...);
     }
-#endif
+
     //! destroy an object of type T (i.e. call the destructor)
     void destroy(pointer p)
     {
diff --git a/dune/common/mallocallocator.hh b/dune/common/mallocallocator.hh
index 4892e947f..65f6764ec 100644
--- a/dune/common/mallocallocator.hh
+++ b/dune/common/mallocallocator.hh
@@ -82,14 +82,14 @@ namespace Dune
     {
       ::new((void*)p)T(val);
     }
-#if HAVE_RVALUE_REFERENCES || DOXYGEN
+
     //! construct an object of type T from variadic parameters
     template<typename ... _Args>
     void construct(pointer p, _Args&&... __args)
     {
       ::new((void *)p)T(std::forward<_Args>(__args) ...);
     }
-#endif
+
     //! destroy an object of type T (i.e. call the destructor)
     void destroy(pointer p)
     {
diff --git a/dune/common/test/typetraitstest.cc b/dune/common/test/typetraitstest.cc
index a2d05bc7a..f344cb26a 100644
--- a/dune/common/test/typetraitstest.cc
+++ b/dune/common/test/typetraitstest.cc
@@ -24,9 +24,7 @@ int main() {
   // Test TypeTraits::isReference
   assert( not Dune::TypeTraits<int>::isReference );
   assert(     Dune::TypeTraits<int&>::isReference );
-#if HAVE_RVALUE_REFERENCES
   assert( not Dune::TypeTraits<int&&>::isReference );
-#endif
 
   // Test TypeTraits::PointeeType
   assert( (Dune::is_same<Dune::Empty, Dune::TypeTraits<int>::PointeeType>::value) );
@@ -48,9 +46,7 @@ int main() {
   // Test is_reference
   assert( not Dune::is_lvalue_reference<int>::value );
   assert(     Dune::is_lvalue_reference<int&>::value );
-#if HAVE_RVALUE_REFERENCES
   assert( not Dune::is_lvalue_reference<int&&>::value );
-#endif
 
   // Test remove_pointer
   // Note: when the argument T is not a pointer, TypeTraits::PointeeType returns Dune::Empty,
@@ -64,9 +60,7 @@ int main() {
   // Test remove_reference
   assert( (Dune::is_same<int, Dune::remove_reference<int>::type>::value) );
   assert( (Dune::is_same<int, Dune::remove_reference<int&>::type>::value) );
-#if HAVE_RVALUE_REFERENCES
   assert( (Dune::is_same<int, Dune::remove_reference<int&&>::type>::value) );
-#endif
 
   return 0;
 }
diff --git a/m4/CMakeLists.txt b/m4/CMakeLists.txt
index e089cce1b..beaa0b3b3 100644
--- a/m4/CMakeLists.txt
+++ b/m4/CMakeLists.txt
@@ -8,7 +8,6 @@ install(PROGRAMS
         ax_lang_compiler_ms.m4
         boost_fusion.m4
         cxx0x_compiler.m4
-        cxx0x_rvaluereference.m4
         cxx0x_nullptr.m4
         cxx11_constexpr.m4
         cxx11_final.m4
diff --git a/m4/Makefile.am b/m4/Makefile.am
index f1672927f..29b1e5c2c 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -11,7 +11,6 @@ ALLM4S = 					\
 	ax_lang_compiler_ms.m4			\
 	boost_fusion.m4				\
 	cxx0x_compiler.m4			\
-	cxx0x_rvaluereference.m4		\
 	cxx0x_nullptr.m4			\
 	cxx11_constexpr.m4			\
 	cxx11_final.m4				\
diff --git a/m4/cxx0x_rvaluereference.m4 b/m4/cxx0x_rvaluereference.m4
deleted file mode 100644
index 74e649a38..000000000
--- a/m4/cxx0x_rvaluereference.m4
+++ /dev/null
@@ -1,32 +0,0 @@
-# tests compiler support for C++0x rvalue references
-# the associated macro is called HAVE_RVALUE_REFERENCES
-
-AC_DEFUN([RVALUE_REFERENCES_CHECK],[
-  AC_CACHE_CHECK([whether rvalue references are supported], dune_cv_rvalue_references_support, [
-    AC_REQUIRE([AC_PROG_CXX])
-    AC_REQUIRE([GXX0X])
-    AC_LANG_PUSH([C++])
-    AC_RUN_IFELSE([
-      AC_LANG_PROGRAM([#include<cassert>
-        #include <utility>
-        int foo(int&& x) { return 1; }
-        int foo(const int& x) { return -1; }
-
-        template<typename T>
-        int forward(T&& x)
-        {
-            return foo(std::forward<T>(x));
-        }], 
-        [
-          int i = 0;
-          assert( forward(i) + forward(int(2)) == 0);
-          return 0;
-        ])],
-      dune_cv_rvalue_references_support=yes,
-      dune_cv_rvalue_references_support=no)
-      AC_LANG_POP
-  ])
-  if test "x$dune_cv_rvalue_references_support" = xyes; then
-    AC_DEFINE(HAVE_RVALUE_REFERENCES, 1, [Define to 1 if rvalue references are supported])
-  fi
-])
diff --git a/m4/dune_common.m4 b/m4/dune_common.m4
index ddf634cda..f1fa4d423 100644
--- a/m4/dune_common.m4
+++ b/m4/dune_common.m4
@@ -20,7 +20,6 @@ AC_DEFUN([DUNE_COMMON_CHECKS],
   AC_REQUIRE([DUNE_CHECK_COMPILER])
   AC_REQUIRE([GXX0X])
   AC_REQUIRE([NULLPTR_CHECK])
-  AC_REQUIRE([RVALUE_REFERENCES_CHECK])
   AC_REQUIRE([CXX11_CONSTEXPR_CHECK])
   AC_REQUIRE([DUNE_BOOST_BASE])
   AC_REQUIRE([DUNE_LINKCXX])
-- 
GitLab