From c0180d762a456db765c7e3ecb335e3e17445cf7e Mon Sep 17 00:00:00 2001
From: Jean-Paul Pelteret <jppelteret@gmail.com>
Date: Thu, 12 Apr 2018 14:41:19 +0200
Subject: [PATCH] Update Adol-C number types.

Default definitions for helper functions are now given irrespective of
whether deal.II is compiled with Adol-C or not. This assists in generic
programming.
---
 .../differentiation/ad/adolc_number_types.h   | 98 ++++++++++++++-----
 1 file changed, 72 insertions(+), 26 deletions(-)

diff --git a/include/deal.II/differentiation/ad/adolc_number_types.h b/include/deal.II/differentiation/ad/adolc_number_types.h
index 240730c5bf..dd75c8e67d 100644
--- a/include/deal.II/differentiation/ad/adolc_number_types.h
+++ b/include/deal.II/differentiation/ad/adolc_number_types.h
@@ -17,22 +17,6 @@
 #define dealii_differentiation_ad_adolc_number_types_h
 
 #include <deal.II/base/config.h>
-
-#ifdef DEAL_II_WITH_ADOLC
-
-#include <adolc/internal/adolc_settings.h>
-#include <adolc/internal/adubfunc.h> // Taped double math functions
-
-#include <adolc/adouble.h> // Taped double
-#include <adolc/adtl.h>    // Tapeless double
-
-#include <deal.II/base/numbers.h>
-#include <deal.II/base/exceptions.h>
-
-#include <deal.II/differentiation/ad/ad_number_types.h>
-#include <deal.II/differentiation/ad/ad_number_traits.h>
-
-#include <complex>
 #include <type_traits>
 
 DEAL_II_NAMESPACE_OPEN
@@ -50,11 +34,62 @@ namespace Differentiation
      * @author Jean-Paul Pelteret, 2017
      */
     template <typename NumberType, typename = void>
-    struct is_adolc_number;
+    struct is_adolc_number
+      : std::false_type
+    {};
+
+
+    /**
+     * A struct to indicate whether a given @p NumberType is a taped
+     * Adol-C number or not. By default, numbers are not considered to
+     * have the necessary characteristics to fulfill this condition.
+     *
+     * @author Jean-Paul Pelteret, 2017
+     */
+    template <typename NumberType, typename = void>
+    struct is_adolc_taped_number
+      : std::false_type
+    {};
+
+
+    /**
+     * A struct to indicate whether a given @p NumberType is a tapeless
+     * Adol-C number or not. By default, numbers are not considered to
+     * have the necessary characteristics to fulfill this condition.
+     *
+     * @author Jean-Paul Pelteret, 2017
+     */
+    template <typename NumberType, typename = void>
+    struct is_adolc_tapeless_number
+      : std::false_type
+    {};
   }
 }
 
 
+DEAL_II_NAMESPACE_CLOSE
+
+
+#ifdef DEAL_II_WITH_ADOLC
+
+#include <adolc/internal/adolc_settings.h>
+#include <adolc/internal/adubfunc.h> // Taped double math functions
+
+#include <adolc/adouble.h> // Taped double
+#include <adolc/adtl.h>    // Tapeless double
+
+#include <deal.II/base/numbers.h>
+#include <deal.II/base/exceptions.h>
+
+#include <deal.II/differentiation/ad/ad_number_types.h>
+#include <deal.II/differentiation/ad/ad_number_traits.h>
+
+#include <complex>
+#include <type_traits>
+
+DEAL_II_NAMESPACE_OPEN
+
+
 /* --------------------------- inline and template functions and specializations ------------------------- */
 
 
@@ -435,18 +470,29 @@ namespace Differentiation
     {};
 
 
-
     /**
-     * A struct to indicate whether a given @p NumberType is an
-     * Adol-C number or not. By default, numbers are not considered to
-     * have the necessary characteristics to fulfill this condition.
+     * Specialization of the struct for the case when the input template
+     * parameter is a (real or complex) taped Adol-C number.
      */
-    template <typename NumberType, typename>
-    struct is_adolc_number
-      : std::false_type
+    template <typename NumberType>
+    struct is_adolc_taped_number<NumberType, typename std::enable_if<
+      ADNumberTraits<typename std::decay<NumberType>::type>::type_code == NumberTypes::adolc_taped
+      >::type>
+      : std::true_type
     {};
 
 
+    /**
+     * Specialization of the struct for the case when the input template
+     * parameter is a (real or complex) tapeless Adol-C number.
+     */
+    template <typename NumberType>
+    struct is_adolc_tapeless_number<NumberType, typename std::enable_if<
+      ADNumberTraits<typename std::decay<NumberType>::type>::type_code == NumberTypes::adolc_tapeless
+      >::type>
+      : std::true_type
+    {};
+
 
     /**
      * Specialization of the struct for the case when the input template
@@ -454,8 +500,8 @@ namespace Differentiation
      */
     template <typename NumberType>
     struct is_adolc_number<NumberType, typename std::enable_if<
-      ADNumberTraits<typename std::decay<NumberType>::type>::type_code == NumberTypes::adolc_taped ||
-      ADNumberTraits<typename std::decay<NumberType>::type>::type_code == NumberTypes::adolc_tapeless
+      is_adolc_taped_number<NumberType>::value ||
+      is_adolc_tapeless_number<NumberType>::value
       >::type>
       : std::true_type
     {};
-- 
2.39.5