From ddffc6c03ce4a067fcaaeec0919cfd238da928cc Mon Sep 17 00:00:00 2001 From: Christopher McArthur Date: Thu, 21 May 2020 22:04:21 -0400 Subject: [PATCH] detection idiom to help validate traits --- include/jwt-cpp/jwt.h | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/include/jwt-cpp/jwt.h b/include/jwt-cpp/jwt.h index f3fb5e8..970bab8 100644 --- a/include/jwt-cpp/jwt.h +++ b/include/jwt-cpp/jwt.h @@ -774,6 +774,53 @@ namespace jwt { } namespace details { + template struct make_void + { + using type = void; + }; + template using void_t = typename make_void::type; + struct nonesuch + { + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; + nonesuch(nonesuch const&&) = delete; + void operator=(nonesuch const&) = delete; + void operator=(nonesuch&&) = delete; + }; + + template class Op, + class... Args> + struct detector + { + using value_t = std::false_type; + using type = Default; + }; + + template class Op, class... Args> + struct detector>, Op, Args...> + { + using value_t = std::true_type; + using type = Op; + }; + + template