mirror of
https://github.com/arun11299/cpp-jwt.git
synced 2025-05-15 09:18:33 +00:00
Fix type concept check. Remove refernce to get key_type et al
This commit is contained in:
parent
fc294cbc8a
commit
973e7e0249
4 changed files with 30 additions and 25 deletions
|
@ -31,7 +31,7 @@ struct empty_type {};
|
|||
/**
|
||||
*/
|
||||
template <typename T, typename=void>
|
||||
struct has_create_json_obj_member: std::false_type
|
||||
struct has_create_json_obj_member
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -72,22 +72,21 @@ template <typename T>
|
|||
struct is_mapping_concept<T,
|
||||
void_t<
|
||||
typename std::enable_if<
|
||||
std::is_constructible<jwt::string_view, typename T::key_type>::value,
|
||||
std::is_constructible<jwt::string_view, typename std::remove_reference_t<T>::key_type>::value,
|
||||
void
|
||||
>::type,
|
||||
|
||||
typename std::enable_if<
|
||||
std::is_constructible<jwt::string_view, typename T::mapped_type>::value,
|
||||
std::is_constructible<jwt::string_view, typename std::remove_reference_t<T>::mapped_type>::value,
|
||||
void
|
||||
>::type,
|
||||
|
||||
decltype(
|
||||
std::declval<T&>().operator[](std::declval<const typename T::key_type&>()),
|
||||
std::declval<T&>().operator[](std::declval<typename std::remove_reference_t<T>::key_type>()),
|
||||
std::declval<T&>().begin(),
|
||||
std::declval<T&>().end(),
|
||||
(void)0
|
||||
)
|
||||
|
||||
>
|
||||
>: std::true_type
|
||||
{
|
||||
|
|
|
@ -107,16 +107,6 @@ struct headers_param
|
|||
using param_init_list_t = std::initializer_list<std::pair<jwt::string_view, jwt::string_view>>;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
template <typename MappingConcept,
|
||||
typename=typename jwt::detail::meta::is_mapping_concept<MappingConcept>::type>
|
||||
detail::payload_param<MappingConcept>
|
||||
payload(MappingConcept&& mc)
|
||||
{
|
||||
return { std::forward<MappingConcept>(mc) };
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
detail::payload_param<std::unordered_map<std::string, std::string>>
|
||||
|
@ -131,6 +121,18 @@ payload(const param_init_list_t& kvs)
|
|||
return { std::move(m) };
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
template <typename MappingConcept>
|
||||
detail::payload_param<MappingConcept>
|
||||
payload(MappingConcept&& mc)
|
||||
{
|
||||
static_assert (jwt::detail::meta::is_mapping_concept<MappingConcept>::value,
|
||||
"Template parameter does not meet the requirements for MappingConcept.");
|
||||
|
||||
return { std::forward<MappingConcept>(mc) };
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -153,16 +155,6 @@ detail::algorithm_param algorithm(jwt::algorithm alg)
|
|||
return { alg };
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
template <typename MappingConcept,
|
||||
typename=typename jwt::detail::meta::is_mapping_concept<MappingConcept>::type>
|
||||
detail::headers_param<MappingConcept>
|
||||
headers(MappingConcept&& mc)
|
||||
{
|
||||
return { std::forward<MappingConcept>(mc) };
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
detail::headers_param<std::map<std::string, std::string>>
|
||||
|
@ -177,6 +169,18 @@ headers(const param_init_list_t& kvs)
|
|||
return { std::move(m) };
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
template <typename MappingConcept>
|
||||
detail::headers_param<MappingConcept>
|
||||
headers(MappingConcept&& mc)
|
||||
{
|
||||
static_assert (jwt::detail::meta::is_mapping_concept<MappingConcept>::value,
|
||||
"Template parameter does not meet the requirements for MappingConcept.");
|
||||
|
||||
return { std::forward<MappingConcept>(mc) };
|
||||
}
|
||||
|
||||
} // END namespace params
|
||||
} // END namespace jwt
|
||||
|
||||
|
|
Binary file not shown.
|
@ -11,12 +11,14 @@ void basic_jwt_object_test()
|
|||
{"a", "b"},
|
||||
{"c", "d"}
|
||||
}));
|
||||
|
||||
//check with std::map
|
||||
std::map<std::string, std::string> m;
|
||||
m["a"] = "b";
|
||||
m["c"] = "d";
|
||||
|
||||
jwt::jwt_object obj1{payload(m)};
|
||||
|
||||
auto obj2 = std::move(obj1);
|
||||
|
||||
std::cout << obj2.payload() << std::endl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue