diff --git a/Sofa/framework/Helper/src/sofa/helper/accessor/ReadAccessor.h b/Sofa/framework/Helper/src/sofa/helper/accessor/ReadAccessor.h index 295b4eefba3..fdf801a9ed6 100644 --- a/Sofa/framework/Helper/src/sofa/helper/accessor/ReadAccessor.h +++ b/Sofa/framework/Helper/src/sofa/helper/accessor/ReadAccessor.h @@ -72,8 +72,8 @@ class ReadAccessor const_reference operator* () const { return *vref; } }; -template -class ReadAccessor::value>> +template +class ReadAccessor : public ReadAccessorFixedArray< FixedArrayLikeType > { public: diff --git a/Sofa/framework/Helper/src/sofa/helper/accessor/ReadAccessorFixedArray.h b/Sofa/framework/Helper/src/sofa/helper/accessor/ReadAccessorFixedArray.h index 62e493e45eb..71cf83fac57 100644 --- a/Sofa/framework/Helper/src/sofa/helper/accessor/ReadAccessorFixedArray.h +++ b/Sofa/framework/Helper/src/sofa/helper/accessor/ReadAccessorFixedArray.h @@ -28,7 +28,7 @@ namespace sofa::helper { ////////////////////////// ReadAccessor for wrapping around fixed array like object ////////////////////// /// ReadAccessor implementation class for fixed array types -template +template class ReadAccessorFixedArray { public: diff --git a/Sofa/framework/Helper/src/sofa/helper/accessor/WriteAccessor.h b/Sofa/framework/Helper/src/sofa/helper/accessor/WriteAccessor.h index bb7269d470a..23b4695b7ef 100644 --- a/Sofa/framework/Helper/src/sofa/helper/accessor/WriteAccessor.h +++ b/Sofa/framework/Helper/src/sofa/helper/accessor/WriteAccessor.h @@ -83,8 +83,8 @@ class WriteAccessor } }; -template -class WriteAccessor::value>> +template +class WriteAccessor : public WriteAccessorFixedArray< FixedArrayLikeType > { public: diff --git a/Sofa/framework/Helper/src/sofa/helper/accessor/WriteAccessorFixedArray.h b/Sofa/framework/Helper/src/sofa/helper/accessor/WriteAccessorFixedArray.h index 0953e07da48..5f6cc826d3c 100644 --- a/Sofa/framework/Helper/src/sofa/helper/accessor/WriteAccessorFixedArray.h +++ b/Sofa/framework/Helper/src/sofa/helper/accessor/WriteAccessorFixedArray.h @@ -27,7 +27,7 @@ namespace sofa::helper { /// WriteAccessor implementation class for fixed array types -template +template class WriteAccessorFixedArray { public: diff --git a/Sofa/framework/Type/src/sofa/type/trait/is_fixed_array.h b/Sofa/framework/Type/src/sofa/type/trait/is_fixed_array.h index 48a1e5166a1..f84787d514d 100644 --- a/Sofa/framework/Type/src/sofa/type/trait/is_fixed_array.h +++ b/Sofa/framework/Type/src/sofa/type/trait/is_fixed_array.h @@ -27,39 +27,17 @@ namespace sofa::type::trait /// Detect if a type T has iterator/const iterator function, operator[](size_t) and defines a static size template -struct is_fixed_array +concept is_fixed_array = requires(std::remove_cv_t t, const std::remove_cv_t ct) { - typedef typename std::remove_const::type test_type; + T::static_size; - template - static constexpr bool test( - A * pt, - A const * cpt = nullptr, - decltype(pt->begin()) * = nullptr, - decltype(pt->end()) * = nullptr, - decltype(cpt->begin()) * = nullptr, - decltype(cpt->end()) * = nullptr, - typename std::decay::type * = nullptr, ///< Is there an operator[] ? - decltype(A::static_size) * = nullptr, ///< fixed array containers define static_size - typename A::iterator * = nullptr, - typename A::const_iterator * = nullptr, - typename A::value_type * = nullptr) - { + {t.begin()} -> std::convertible_to; + {t.end()} -> std::convertible_to; - typedef typename A::iterator iterator; - typedef typename A::const_iterator const_iterator; - return std::is_samebegin()),iterator>::value - && std::is_sameend()),iterator>::value - && std::is_samebegin()),const_iterator>::value - && std::is_sameend()),const_iterator>::value; - } + {ct.begin()} -> std::convertible_to; + {ct.end()} -> std::convertible_to; - template - static constexpr bool test(...) { - return false; - } - - static const bool value = test(nullptr); + { t[0] } -> std::convertible_to; }; }