From 8e47f7b937646cd93843ad0f3b7093469b545463 Mon Sep 17 00:00:00 2001 From: "Brendan K. Krueger" Date: Fri, 13 Sep 2024 14:19:03 -0600 Subject: [PATCH] Change template name to more-standard T. --- ports-of-call/span.hpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ports-of-call/span.hpp b/ports-of-call/span.hpp index c8e2b16c..a9b09a17 100644 --- a/ports-of-call/span.hpp +++ b/ports-of-call/span.hpp @@ -12,10 +12,10 @@ namespace PortsOfCall { // Heavily simplified relative to std::span, but provides a similar concept in a way // that's portable to GPUs. -template +template class span { private: - DataType *ptr_{nullptr}; + T *ptr_{nullptr}; std::size_t size_{0}; public: @@ -33,7 +33,7 @@ class span { // object provides access to indices 2 <= i < 8 of the array my_array, but the indices // are shifted so that sub_range[i] is my_array[i+2]. template - PORTABLE_FUNCTION constexpr span(DataType *ptr, SizeType const &count) + PORTABLE_FUNCTION constexpr span(T *ptr, SizeType const &count) : ptr_{ptr}, size_(count) { assert(count >= 0); } @@ -42,26 +42,26 @@ class span { PORTABLE_FUNCTION constexpr auto size() const { return size_; } // Iterator (really a pointer) to the beginning of the range, providing mutable access. - PORTABLE_FUNCTION constexpr DataType *begin() { return ptr_; } + PORTABLE_FUNCTION constexpr T *begin() { return ptr_; } // Iterator (really a pointer) to the beginning of the range, providing constant access. - PORTABLE_FUNCTION constexpr DataType const *begin() const { return ptr_; } + PORTABLE_FUNCTION constexpr T const *begin() const { return ptr_; } // Iterator (really a pointer) to the beginning of the range, providing constant access. - PORTABLE_FUNCTION constexpr DataType const *cbegin() const { return ptr_; } + PORTABLE_FUNCTION constexpr T const *cbegin() const { return ptr_; } // Iterator (really a pointer) to the end of the range, providing mutable access. - PORTABLE_FUNCTION constexpr DataType *end() { return ptr_ + size_; } + PORTABLE_FUNCTION constexpr T *end() { return ptr_ + size_; } // Iterator (really a pointer) to the beginning of the range, providing constant access. - PORTABLE_FUNCTION constexpr DataType const *end() const { return ptr_ + size_; } + PORTABLE_FUNCTION constexpr T const *end() const { return ptr_ + size_; } // Iterator (really a pointer) to the beginning of the range, providing constant access. - PORTABLE_FUNCTION constexpr DataType const *cend() const { return ptr_ + size_; } + PORTABLE_FUNCTION constexpr T const *cend() const { return ptr_ + size_; } // Index operator to obtain mutable access to an element of the range. template - PORTABLE_FUNCTION constexpr DataType &operator[](Index const &index) { + PORTABLE_FUNCTION constexpr T &operator[](Index const &index) { assert(index >= 0); assert(static_cast(index) < size_); return *(ptr_ + index); @@ -69,7 +69,7 @@ class span { // Index operator to obtain constant access to an element of the range. template - PORTABLE_FUNCTION constexpr DataType const &operator[](Index const &index) const { + PORTABLE_FUNCTION constexpr T const &operator[](Index const &index) const { assert(index >= static_cast(0)); assert(index < static_cast(size_)); return *(ptr_ + index); @@ -78,10 +78,10 @@ class span { // ================================================================================================ -template -PORTABLE_FUNCTION constexpr auto make_span(DataType *const pointer, +template +PORTABLE_FUNCTION constexpr auto make_span(T *const pointer, SizeType const count) { - return span(pointer, count); + return span(pointer, count); } // ================================================================================================