aboutsummaryrefslogtreecommitdiffstats
path: root/include/jau
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-01-09 16:11:11 +0100
committerSven Gothel <[email protected]>2021-01-09 16:11:11 +0100
commit9d1f01c4bddda155f23b620ebb6c2b6bf55173aa (patch)
treede0e92e5e15af1938b950821d955fec439d69fe8 /include/jau
parentba136aa56b96d161daf2d9643f79cc892fa7af12 (diff)
cow_darray, darray: Add type_trait query is_darray_type<T>::value and test_cow_darray_perf01 with default and use_memmove etc.
Diffstat (limited to 'include/jau')
-rw-r--r--include/jau/cow_darray.hpp3
-rw-r--r--include/jau/darray.hpp22
2 files changed, 25 insertions, 0 deletions
diff --git a/include/jau/cow_darray.hpp b/include/jau/cow_darray.hpp
index 68ff414..9fd67cd 100644
--- a/include/jau/cow_darray.hpp
+++ b/include/jau/cow_darray.hpp
@@ -153,6 +153,9 @@ namespace jau {
use_memmove, use_realloc> storage_t;
typedef std::shared_ptr<storage_t> storage_ref_t;
+ /** Used to determine whether this type is a darray or has a darray, see ::is_darray_type<T> */
+ typedef bool darray_tag;
+
typedef cow_darray<value_type, allocator_type,
size_type,
use_memmove, use_realloc> cow_container_t;
diff --git a/include/jau/darray.hpp b/include/jau/darray.hpp
index ffc960b..113a805 100644
--- a/include/jau/darray.hpp
+++ b/include/jau/darray.hpp
@@ -113,6 +113,9 @@ namespace jau {
// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef Alloc_type allocator_type;
+ /** Used to determine whether this type is a darray or has a darray, see ::is_darray_type<T> */
+ typedef bool darray_tag;
+
private:
static constexpr size_type DIFF_MAX = std::numeric_limits<difference_type>::max();
@@ -1071,6 +1074,25 @@ namespace jau {
inline void swap(darray<Value_type, Alloc_type>& rhs, darray<Value_type, Alloc_type>& lhs) noexcept
{ rhs.swap(lhs); }
+ /****************************************************************************************
+ ****************************************************************************************/
+
+ /**
+ * <code>template< class T > is_darray_type<T>::value</code> compile-time Type Trait,
+ * determining whether the given template class is a - or has a darray type, e.g. jau::cow_darray,
+ * jau::darray.
+ */
+ template< class, class = void >
+ struct is_darray_type : std::false_type { };
+
+ /**
+ * <code>template< class T > is_darray_type<T>::value</code> compile-time Type Trait,
+ * determining whether the given template class is a - or has a darray type, e.g. jau::cow_darray,
+ * jau::darray.
+ */
+ template< class T >
+ struct is_darray_type<T, std::void_t<typename T::darray_tag>> : std::true_type { };
+
} /* namespace jau */
#endif /* JAU_DYN_ARRAY_HPP_ */