From e94cccc81fb16ef3fd479dc6b83d91fa8020176f Mon Sep 17 00:00:00 2001 From: Benedek Thaler Date: Thu, 23 Jun 2022 16:23:10 +0200 Subject: [PATCH] Fix has_tag for variant custom tag --- include/binlog/adapt_stdvariant.hpp | 7 +++++++ test/integration/LoggingVariants.cpp | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/include/binlog/adapt_stdvariant.hpp b/include/binlog/adapt_stdvariant.hpp index 0987c99..8b11855 100644 --- a/include/binlog/adapt_stdvariant.hpp +++ b/include/binlog/adapt_stdvariant.hpp @@ -55,6 +55,13 @@ struct CustomSerializer> template struct CustomTag> { + // Make this type not-constructible, if some Tag is not constructible + std::conditional_t< + detail::conjunction...>::value, + std::true_type, + mserialize::detail::BuiltinTag + > tag_guard; + static constexpr auto tag_string() { return cx_strcat( diff --git a/test/integration/LoggingVariants.cpp b/test/integration/LoggingVariants.cpp index e25d99b..0cb8cde 100644 --- a/test/integration/LoggingVariants.cpp +++ b/test/integration/LoggingVariants.cpp @@ -91,3 +91,11 @@ int main() binlog::consume(std::cout); } + +struct Adapted {}; +BINLOG_ADAPT_STRUCT(Adapted) + +struct NotAdapted {}; + +static_assert(mserialize::detail::has_tag>::value, ""); +static_assert(!mserialize::detail::has_tag>::value, "");