is_sequence_concept impl

This commit is contained in:
Arun M 2017-12-05 17:15:37 +05:30
parent a4a4bd5dff
commit 7a7353a9ef
3 changed files with 33 additions and 3 deletions

View file

@ -1,6 +1,7 @@
#ifndef CPP_JWT_META_HPP #ifndef CPP_JWT_META_HPP
#define CPP_JWT_META_HPP #define CPP_JWT_META_HPP
#include <iterator>
#include <type_traits> #include <type_traits>
#include "jwt/string_view.hpp" #include "jwt/string_view.hpp"
@ -123,17 +124,42 @@ struct is_parameter_concept<T,
/** /**
*/ */
/*
template <typename T, typename=void> template <typename T, typename=void>
struct is_sequence_concept: std::false_type struct is_sequence_concept: std::false_type
{ {
}; };
/// For array types
template <typename T> template <typename T>
struct is_sequence_concept<>: std::true_type struct is_sequence_concept<T,
void_t<
std::enable_if_t<std::is_array<std::decay_t<T>>::value>
>
>: std::true_type
{ {
}; };
*/
template <typename T>
struct is_sequence_concept<T,
void_t<
std::enable_if_t<
std::is_base_of<
std::forward_iterator_tag,
typename std::remove_reference_t<T>::iterator::iterator_category
>::value
>,
decltype(
std::declval<T&>().begin(),
std::declval<T&>().end(),
(void)0
)
>
>: std::true_type
{
};
/** /**
* Find if a type is present in the typelist. * Find if a type is present in the typelist.

Binary file not shown.

View file

@ -49,6 +49,8 @@ void basic_jwt_object_test()
void jwt_object_pem_test() void jwt_object_pem_test()
{ {
using namespace jwt::params;
std::string pub_key = std::string pub_key =
R"(-----BEGIN PUBLIC KEY----- R"(-----BEGIN PUBLIC KEY-----
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEomxC9ycc8AkXSwWQpu1kN5Fmgy/sD/KJ MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEomxC9ycc8AkXSwWQpu1kN5Fmgy/sD/KJ
@ -75,6 +77,8 @@ MIGkAgEBBDBeLCgapjZmvTatMHaYX3A02+0Ys3Tr8kda+E9DFnmCSiCOEig519fT
; ;
std::cout << "pem sign " << obj.signature() << std::endl; std::cout << "pem sign " << obj.signature() << std::endl;
auto dec_obj = jwt::decode(obj.signature(), pub_key, algorithms({"es256"}));
std::cout << dec_obj.payload() << std::endl;
} }
int main() { int main() {