Open sherike opened 4 years ago
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: error: no matching function for call to ‘std::set<std::basic_string, jwt::jwt_set::case_compare>::find(const stringview&)’ 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; }
bool add_header(const jwt::string_view hname, T&& hvalue, bool overwrite=false) {
@@ -560,7 +560,7 @@ public: // Exposed APIs { // Duplicate claim names not allowed // if overwrite flag is set to true.
auto itr = claimnames.find(cname.data()); if (itr == claimnames.end()) return false;
claimnames.erase(itr); @@ -708,7 +708,7 @@ public: // Exposed APIs //based overload bool has_claim(const jwt::string_view cname) const noexcept {
return claimnames.find(cname.data()) != std::end(claimnames); }
/** @@ -729,7 +729,7 @@ public: // Exposed APIs template bool has_claim_with_value(const jwt::string_view cname, T&& cvalue) const {
return (cvalue == payload_[cname.data()]);
Sheri ^
i have the same problem, did you find solution?
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: error: no matching function for call to ‘std::set<std::basic_string, jwt::jwt_set::case_compare>::find(const stringview&)’
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
@@ -560,7 +560,7 @@ public: // Exposed APIs { // Duplicate claim names not allowed // if overwrite flag is set to true.
auto itr = claimnames.find(cname.data()); if (itr == claimnames.end()) return false;
claimnames.erase(itr); @@ -708,7 +708,7 @@ public: // Exposed APIs //based overload bool has_claim(const jwt::string_view cname) const noexcept {
return claimnames.find(cname.data()) != std::end(claimnames); }
/** @@ -729,7 +729,7 @@ public: // Exposed APIs template
bool has_claim_with_value(const jwt::string_view cname, T&& cvalue) const
{
auto itr = claimnames.find(cname.data()); if (itr == claimnames.end()) return false;
return (cvalue == payload_[cname.data()]);
Sheri ^