From 0486015477545fbbb82495d1b03b6eb75cc46934 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Mon, 28 Oct 2019 13:10:31 -0700 Subject: [PATCH] Extract a helper constexpr function for templates: IsJavaClassType (#21) Summary: Used in 3 places (more soon), and this is more readable. Pull Request resolved: https://github.com/facebookincubator/fbjni/pull/21 Test Plan: CI Reviewed By: cjhopman Differential Revision: D18138398 Pulled By: dreiss fbshipit-source-id: 70b2a0a88ae278da3d0076fc62f6fb582001ef57 --- first-party/fbjni/cxx/fbjni/detail/References.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/first-party/fbjni/cxx/fbjni/detail/References.h b/first-party/fbjni/cxx/fbjni/detail/References.h index c1f46d4d9d0..eaac4c4dd58 100644 --- a/first-party/fbjni/cxx/fbjni/detail/References.h +++ b/first-party/fbjni/cxx/fbjni/detail/References.h @@ -135,6 +135,11 @@ class JClass; namespace detail { +template +constexpr bool IsJavaClassType() { + return std::is_base_of::value; +} + template struct HasJniRefRepr : std::false_type {}; @@ -146,16 +151,16 @@ struct HasJniRefRepr struct RefReprType { using type = typename std::conditional::value, typename HasJniRefRepr::type, JObjectWrapper>::type; - static_assert(std::is_base_of::value, + static_assert(IsJavaClassType(), "Repr type missing JObject base."); static_assert(std::is_same::type>::value, "RefReprType not idempotent"); }; template -struct RefReprType::value, void>::type> { +struct RefReprType(), void>::type> { using type = T; - static_assert(std::is_base_of::value, + static_assert(IsJavaClassType(), "Repr type missing JObject base."); static_assert(std::is_same::type>::value, "RefReprType not idempotent");