From 0cd0b4da5a8d9aee778e8394741d4048e20e5642 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <jan.travnicek@.fit.cvut.cz> Date: Wed, 29 May 2019 14:49:53 +0200 Subject: [PATCH] fix use of c-array in has_clone trait --- alib2std/src/extensions/type_traits.hpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/alib2std/src/extensions/type_traits.hpp b/alib2std/src/extensions/type_traits.hpp index a9b177a9d0..21e496c8a8 100644 --- a/alib2std/src/extensions/type_traits.hpp +++ b/alib2std/src/extensions/type_traits.hpp @@ -39,20 +39,18 @@ namespace ext { template<class T> struct has_clone { private: - typedef char (&Yes)[1]; - typedef char (&No)[2]; - - template<class U> - static Yes test(U * data, typename std::enable_if< std::is_pointer<decltype(data->clone())>::value>::type * = nullptr); - static No test(...); + template < class U > + static std::true_type test ( U * data, typename std::enable_if < std::is_pointer_v < decltype ( data->clone ( ) ) > >::type * = nullptr ); + static std::false_type test ( ... ); public: /** * \brief * True if the type decayed type T has clone method. */ - static const bool value = sizeof(Yes) == sizeof(has_clone::test((typename std::decay<T>::type*)nullptr)); + static const bool value = decltype ( has_clone::test ( std::declval < std::decay_t < T > * > ( ) ) )::value; }; + /** * \brief * Positive supports test implementation. The test is designed to detect call availability on callable F with parameters Ts ... -- GitLab