Blob Blame History Raw
With GCC 9.0, the original code leads to this GCC error:

non-type template parameters of class type only available with '-std=c++2a' or '-std=gnu++2a'

We do not need to support arbitrary non-type template parameters in this code.
In practice, the type is usually either bool or int.  This patch restricts the
type to a scalar type, which avoids the GCC error.

diff -up lemon-1.3.1/lemon/maps.h.orig lemon-1.3.1/lemon/maps.h
--- lemon-1.3.1/lemon/maps.h.orig	2014-07-07 08:40:24.957315761 -0600
+++ lemon-1.3.1/lemon/maps.h	2019-04-01 16:19:57.794983389 -0600
@@ -23,6 +23,7 @@
 #include <functional>
 #include <vector>
 #include <map>
+#include <type_traits>
 
 #include <lemon/core.h>
 
@@ -149,7 +150,7 @@ namespace lemon {
   }
 
 
-  template<typename T, T v>
+  template<typename T, typename std::enable_if<std::is_scalar<T>::value,T>::type v>
   struct Const {};
 
   /// Constant map with inlined constant value.
@@ -166,7 +167,7 @@ namespace lemon {
   ///
   /// \sa NullMap
   /// \sa IdentityMap
-  template<typename K, typename V, V v>
+  template<typename K, typename V, typename std::enable_if<std::is_scalar<V>::value,V>::type v>
   class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
   public:
     ///\e
@@ -189,7 +190,7 @@ namespace lemon {
   /// This function just returns a \c ConstMap class with inlined
   /// constant value.
   /// \relates ConstMap
-  template<typename K, typename V, V v>
+  template<typename K, typename V, typename std::enable_if<std::is_scalar<V>::value,V>::type v>
   inline ConstMap<K, Const<V, v> > constMap() {
     return ConstMap<K, Const<V, v> >();
   }