make template specialization more clear

v1
Brett 2024-02-14 15:25:18 -05:00
parent ea31d8f26c
commit 8e5b3ed284
1 changed files with 15 additions and 22 deletions

View File

@ -81,6 +81,9 @@ namespace blt
V* _v; V* _v;
}; };
template<typename T, bool = std::is_copy_constructible_v<T> || std::is_copy_assignable_v<T>>
class scoped_buffer;
/** /**
* Creates an encapsulation of a T array which will be automatically deleted when this object goes out of scope. * Creates an encapsulation of a T array which will be automatically deleted when this object goes out of scope.
* This is a simple buffer meant to be used only inside of a function and not copied around. * This is a simple buffer meant to be used only inside of a function and not copied around.
@ -88,8 +91,8 @@ namespace blt
* The operator * has been overloaded to return the internal buffer. * The operator * has been overloaded to return the internal buffer.
* @tparam T type that is stored in buffer eg char * @tparam T type that is stored in buffer eg char
*/ */
template<typename T, bool = std::is_copy_constructible_v<T> || std::is_copy_assignable_v<T>> template<typename T>
class scoped_buffer class scoped_buffer<T, true>
{ {
public: public:
using element_type = T; using element_type = T;
@ -248,16 +251,6 @@ namespace blt
return buffer_; return buffer_;
} }
// inline auto begin()
// {
// return ptr_iterator{buffer_};
// }
//
// inline ptr_iterator<T> end()
// {
// return ptr_iterator{&buffer_[size_]};
// }
constexpr iterator begin() noexcept constexpr iterator begin() noexcept
{ {
return iterator{data()}; return iterator{data()};
@ -304,6 +297,16 @@ namespace blt
} }
}; };
template<typename T>
class scoped_buffer<T, false> : scoped_buffer<T, true>
{
using scoped_buffer<T, true>::scoped_buffer;
public:
scoped_buffer(const scoped_buffer& copy) = delete;
scoped_buffer operator=(scoped_buffer& copyAssignment) = delete;
};
template<typename T, size_t MAX_SIZE> template<typename T, size_t MAX_SIZE>
class static_vector class static_vector
{ {
@ -388,16 +391,6 @@ namespace blt
} }
}; };
template<typename T>
class scoped_buffer<T, false> : scoped_buffer<T, true>
{
using scoped_buffer<T, true>::scoped_buffer;
public:
scoped_buffer(const scoped_buffer& copy) = delete;
scoped_buffer operator=(scoped_buffer& copyAssignment) = delete;
};
template<typename T> template<typename T>
struct nullptr_initializer struct nullptr_initializer
{ {