From a531387d0f2ef8fcd289f2071afd92ec34073e06 Mon Sep 17 00:00:00 2001 From: Justus Calvin Date: Tue, 16 Apr 2024 09:00:14 -0700 Subject: [PATCH] Consolidate has_data and has_data_v There are two separate implementations for `has_data` and `has_data_v` that do the same thing. This change combines those implementations. --- btas/tensor_traits.h | 14 -------------- btas/type_traits.h | 20 ++++++++++++++++---- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/btas/tensor_traits.h b/btas/tensor_traits.h index fdd96bad..d9d90462 100644 --- a/btas/tensor_traits.h +++ b/btas/tensor_traits.h @@ -9,20 +9,6 @@ namespace btas { -/// test T has data() member -/// this will be used to detect whether or not the storage is consecutive -template -class has_data { - /// true case - template - static auto __test(U* p) -> decltype(p->data(), std::true_type()); - /// false case - template - static std::false_type __test(...); -public: - static constexpr const bool value = std::is_same(0))>::value; -}; - /// test T has range_type template class has_range_type { diff --git a/btas/type_traits.h b/btas/type_traits.h index af466612..e1e3dca6 100644 --- a/btas/type_traits.h +++ b/btas/type_traits.h @@ -125,10 +125,22 @@ namespace btas { template constexpr inline bool has_squarebraket_v = has_squarebraket::value; - template - constexpr static bool has_data_v = false; - template - constexpr static bool has_data_v().data())>> = true; + /// test T has data() member + /// this will be used to detect whether or not the storage is consecutive + template + class has_data { + /// true case + template + static auto __test(U* p) -> decltype(p->data(), std::true_type()); + /// false case + template + static std::false_type __test(...); + public: + static constexpr const bool value = std::is_same(0))>::value; + }; + + template + inline constexpr bool has_data_v = has_data::value; template constexpr static bool has_size_v = false;