]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Wrap boost::enable_if_c as std_cxx11::enable_if. 1717/head
authorDavid Wells <wellsd2@rpi.edu>
Mon, 5 Oct 2015 15:18:05 +0000 (11:18 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Mon, 5 Oct 2015 15:47:24 +0000 (11:47 -0400)
Note that boost::enable_if is not quite the same thing as std::enable_if
from the C++11 standard library.

This cleans up some of the memory consumption code.

include/deal.II/base/memory_consumption.h
include/deal.II/base/std_cxx11/type_traits.h

index 58e9fcbb54f80e79e32b2dc2bbf63965fb9af653..20dc2fed48e9a02cbaed3e553a1b35ae8ee526fa 100644 (file)
 #include <deal.II/base/std_cxx11/type_traits.h>
 #include <deal.II/base/std_cxx11/unique_ptr.h>
 
-// unfortunately, boost::enable_if_c, not boost::enable_if, is equivalent to
-// std::enable_if
-#include <boost/utility/enable_if.hpp>
-
 #include <string>
 #include <complex>
 #include <vector>
@@ -100,7 +96,7 @@ namespace MemoryConsumption
    */
   template <typename T>
   inline
-  typename boost::enable_if_c<std_cxx11::is_fundamental<T>::value, std::size_t>::type
+  typename std_cxx11::enable_if<std_cxx11::is_fundamental<T>::value, std::size_t>::type
   memory_consumption (const T &t);
 
   /**
@@ -111,7 +107,7 @@ namespace MemoryConsumption
    */
   template <typename T>
   inline
-  typename boost::enable_if_c<!(std_cxx11::is_fundamental<T>::value || std_cxx11::is_pointer<T>::value), std::size_t>::type
+  typename std_cxx11::enable_if<!(std_cxx11::is_fundamental<T>::value || std_cxx11::is_pointer<T>::value), std::size_t>::type
   memory_consumption (const T &t);
 
   /**
@@ -248,7 +244,7 @@ namespace MemoryConsumption
 {
   template <typename T>
   inline
-  typename boost::enable_if_c<std_cxx11::is_fundamental<T>::value, std::size_t>::type
+  typename std_cxx11::enable_if<std_cxx11::is_fundamental<T>::value, std::size_t>::type
   memory_consumption(const T &)
   {
     return sizeof(T);
@@ -380,7 +376,7 @@ namespace MemoryConsumption
 
   template <typename T>
   inline
-  typename boost::enable_if_c<!(std_cxx11::is_fundamental<T>::value || std_cxx11::is_pointer<T>::value), std::size_t>::type
+  typename std_cxx11::enable_if<!(std_cxx11::is_fundamental<T>::value || std_cxx11::is_pointer<T>::value), std::size_t>::type
   memory_consumption (const T &t)
   {
     return t.memory_consumption();
index 114485d1e9fd64180e673cd32c8803020de6ee9f..261f67392eccb0064bb15bb37e795a5720a09e98 100644 (file)
@@ -32,12 +32,14 @@ namespace std_cxx11
   using std::is_pointer;
   using std::is_standard_layout;
   using std::is_trivial;
+  using std::enable_if;
 }
 DEAL_II_NAMESPACE_CLOSE
 
 #else
 
 #include <boost/type_traits.hpp>
+#include <boost/core/enable_if.hpp>
 DEAL_II_NAMESPACE_OPEN
 namespace std_cxx11
 {
@@ -45,6 +47,11 @@ namespace std_cxx11
   using boost::is_pod;
   using boost::is_pointer;
 
+  // boost::enable_if_c, *not* boost::enable_if, is equivalent to std::enable_if.
+  template <bool B, class T = void>
+  struct enable_if : public boost::enable_if_c<B, T>
+  {};
+
   // boost does not have is_standard_layout and
   // is_trivial, but those are both a subset of
   // is_pod

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.