From 9487758b8ce70cd97ddf749de9ec3aadeebed738 Mon Sep 17 00:00:00 2001
From: Arun M <arun11299@gmail.com>
Date: Wed, 3 Jan 2018 10:59:35 +0530
Subject: [PATCH] Compilation works with g++ 6.4

---
 CMakeLists.txt            |  1 +
 include/jwt/algorithm.hpp |  1 +
 include/jwt/impl/jwt.ipp  | 18 +++---------------
 include/jwt/jwt.hpp       | 16 ++++++++++++++--
 4 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b6742f0..ab398cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,7 @@
 cmake_minimum_required (VERSION 2.8.11)
 project (cpp-jwt)
 
+#SET (CMAKE_CXX_COMPILER /usr/local/bin/g++)
 SET( CMAKE_CXX_FLAGS  "-std=c++14" )
 
 include_directories (include)
diff --git a/include/jwt/algorithm.hpp b/include/jwt/algorithm.hpp
index 799178b..83c8ee9 100644
--- a/include/jwt/algorithm.hpp
+++ b/include/jwt/algorithm.hpp
@@ -31,6 +31,7 @@ SOFTWARE.
  */
 
 #include <cassert>
+#include <memory>
 #include <system_error>
 
 #include <openssl/bn.h>
diff --git a/include/jwt/impl/jwt.ipp b/include/jwt/impl/jwt.ipp
index ce5744c..0ba78a1 100644
--- a/include/jwt/impl/jwt.ipp
+++ b/include/jwt/impl/jwt.ipp
@@ -52,9 +52,7 @@ std::ostream& write(std::ostream& os, const T& obj, bool pretty)
 }
 
 
-template <typename T,
-          typename = typename std::enable_if<
-            detail::meta::has_create_json_obj_member<T>{}>::type>
+template <typename T, typename Cond>
 std::ostream& operator<< (std::ostream& os, const T& obj)
 {
   os << obj.create_json_obj();
@@ -344,16 +342,6 @@ void jwt_object::set_parameters()
   return;
 }
 
-template <typename T,
-          typename=typename std::enable_if_t<
-            !std::is_same<system_time_t, std::decay_t<T>>::value>
-         >
-jwt_object& jwt_object::add_claim(const jwt::string_view name, T&& value)
-{
-  payload_.add_claim(name, std::forward<T>(value));
-  return *this;
-}
-
 jwt_object& jwt_object::add_claim(const jwt::string_view name, system_time_t tp)
 {
   return add_claim(
@@ -406,9 +394,9 @@ std::error_code jwt_object::verify(
   //is any of the one expected by the client.
   auto fitr = std::find_if(algos.get().begin(), 
                            algos.get().end(),
-                           [&](const auto& elem) 
+                           [this](const auto& elem) 
                            {
-                             return jwt::str_to_alg(elem) == header().algo();
+                             return jwt::str_to_alg(elem) == this->header().algo();
                            });
 
   if (fitr == algos.get().end()) {
diff --git a/include/jwt/jwt.hpp b/include/jwt/jwt.hpp
index 4247d2e..2e4e527 100644
--- a/include/jwt/jwt.hpp
+++ b/include/jwt/jwt.hpp
@@ -177,6 +177,12 @@ std::string to_json_str(const T& obj, bool pretty=false);
 template <typename T>
 std::ostream& write(std::ostream& os, const T& obj, bool pretty=false);
 
+template <typename T,
+          typename = typename std::enable_if<
+                      detail::meta::has_create_json_obj_member<T>{}>::type
+         >
+std::ostream& operator<< (std::ostream& os, const T& obj);
+
 
 /**
  * A helper class providing the necessary functionalities
@@ -945,8 +951,14 @@ public: // Exposed APIs
    * Provides the glue interface for adding claim.
    * @note: See `jwt_payload::add_claim` for more details.
    */
-  template <typename T, typename Cond>
-  jwt_object& add_claim(const jwt::string_view name, T&& value);
+  template <typename T,
+            typename=typename std::enable_if_t<
+              !std::is_same<system_time_t, std::decay_t<T>>::value>>
+  jwt_object& add_claim(const jwt::string_view name, T&& value)
+  {
+    payload_.add_claim(name, std::forward<T>(value));
+    return *this;
+  }
 
   /**
    * Provides the glue interface for adding claim.