Open josephofthebread opened 1 year ago
This look really valid, feel free to submit a PR.
Unfortunately, I don't think there is any possible solution to provide support for custom strings without rewriting the whole codebase. This will destroy backwards compatibility since, for example, all member of namespace algorithm should be template classes, which means that users would always have to provide boilerplate template deduction hint:
// this:
sign(jwt::algorithm::hs256<MyAwesomeStringType>{"secret"});
// instead of this:
sign(jwt::algorithm::hs256{"secret"});
This problem, however can be done with function aliases, as follows:
namespace jwt::algorithm {
template<typename StringLike>
struct hs256_struct {}; // instead of hs256
template<typename StringLike>
hs256_struct<StringLike> hs256(StringLike secret) {}
}
However, as I mentioned earlier, this will destroy backwards compatibility ... I honestly don't think this library would ever support custom string types.
Btw, when I started exploring library source code, I found this. Nlohmann json implementation supports custom string types for a long time already and I think deprecating support for them just because in 2017 it wasn't supporting that sounds kinda silly.
Anyway, thanks for support!
What happened?
Hey, I am implementing JWT authorization for my http server. My server uses custom allocator and custom memory management system, since on Apple silicon there are not many tools for profiling. I am using nlohmann json implementation. Compilation fails with the following error message:
What I am considering to be going on is that there is no specialization for base::encode to take std::string with custom allocator (code):
Compiler version:
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Compilation options:-Wno-missing-braces -Wdouble-promotion -Wsign-conversion -Wunused-variable --std=c++20 -glldb
How To Reproduce?
Code:
Json traits:
Aliases
Version
0.6.0
What OS are you seeing the problem on?
MacOS
What compiler are you seeing the problem on?
Clang
Relevant log output
No response
Code of Conduct