-
Notifications
You must be signed in to change notification settings - Fork 121
Description
I tried incorporating the project code and use it in a unit test. but when i try to compile it i get the errors below.
pp-jwt/include/jwt/jwt.hpp:449:31: erro**r: no matching function for call to ‘**std::set<std::basic_string, jwt::jwt_set::case_compare>::find(const string_view&)’
return headers_.find(hname) != std::end(headers_);
^
/cpp-jwt/include/jwt/jwt.hpp:449:31: note: candidates are:
/include/c++/4.9/set:61:0,
finclude/jwt/jwt.hpp:26,
/unit_test/cpp-jwt.cpp:7:
include/c++/4.9/bits/stl_set.h:701:7: note: std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) [with _Key = std::basic_string; _Compare = jwt::jwt_set::case_compare; _Alloc = std::allocator<std::basic_string >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<std::basic_string >; std::set<_Key, _Compare, _Alloc>::key_type = std::basic_string]
find(const key_type& __x)
^
include/c++/4.9/bits/stl_set.h:701:7: note: no known conversion for argument 1 from ‘const string_view {aka const jwt::basic_string_view}’ to ‘const key_type& {aka const std::basic_string&}’
include/c++/4.9/bits/stl_set.h:705:7: note: std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = std::basic_string; _Compare = jwt::jwt_set::case_compare; _Alloc = std::allocator<std::basic_string >; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::basic_string >; std::set<_Key, _Compare, _Alloc>::key_type = std::basic_string]
find(const key_type& __x) const
I managed to overcome the problem by replacing all the calls to headers_.find(hname) with headers_.find(hname.data())
any idea why I'm encountering this problem or if i did something wrong ?- a/include/jwt/jwt.hpp
+++ b/include/jwt/jwt.hpp
@@ -394,7 +394,7 @@ public: // Exposed APIs
>
bool add_header(const jwt::string_view hname, T&& hvalue, bool overwrite=false)
{
- auto itr = headers_.find(hname);
- auto itr = headers_.find(hname.data());
if (itr != std::end(headers_) && !overwrite) {
return false;
}
@@ -429,7 +429,7 @@ public: // Exposed APIs
return true;
}
- auto itr = headers_.find(hname);
- auto itr = headers_.find(hname.data());
if (itr == std::end(headers_)) {
return false;
}
@@ -446,7 +446,7 @@ public: // Exposed APIs
bool has_header(const jwt::string_view hname)
{
if (!strcasecmp(hname.data(), "typ")) return typ_ != type::NONE;
- return headers_.find(hname) != std::end(headers_);
- return headers_.find(hname.data()) != std::end(headers_);
}
@@ -560,7 +560,7 @@ public: // Exposed APIs
{
// Duplicate claim names not allowed
// if overwrite flag is set to true.
- auto itr = claim_names_.find(cname);
- auto itr = claim_names_.find(cname.data());
if (itr != claim_names_.end() && !overwrite) {
return false;
}
@@ -679,7 +679,7 @@ public: // Exposed APIs
*/
bool remove_claim(const jwt::string_view cname)
{
- auto itr = claim_names_.find(cname);
-
auto itr = claim_names_.find(cname.data());
if (itr == claim_names_.end()) return false;claim_names_.erase(itr);
@@ -708,7 +708,7 @@ public: // Exposed APIs
//based overload
bool has_claim(const jwt::string_view cname) const noexcept
{
- return claim_names_.find(cname) != std::end(claim_names_);
- return claim_names_.find(cname.data()) != std::end(claim_names_);
}
/**
@@ -729,7 +729,7 @@ public: // Exposed APIs
template
bool has_claim_with_value(const jwt::string_view cname, T&& cvalue) const
{
- auto itr = claim_names_.find(cname);
-
auto itr = claim_names_.find(cname.data());
if (itr == claim_names_.end()) return false;return (cvalue == payload_[cname.data()]);
Sheri
^