Add usz alias for std::size_t

This commit is contained in:
Nekotekina 2020-12-18 10:39:54 +03:00
parent 360c4d1554
commit fb29933d3d
173 changed files with 718 additions and 717 deletions

View file

@ -72,15 +72,15 @@ namespace stx
atomic_t<void (*)(shared_counter* _this) noexcept> destroy{};
// Reference counter
atomic_t<std::size_t> refs{1};
atomic_t<usz> refs{1};
};
template <std::size_t Size, std::size_t Align, typename = void>
template <usz Size, usz Align, typename = void>
struct align_filler
{
};
template <std::size_t Size, std::size_t Align>
template <usz Size, usz Align>
struct align_filler<Size, Align, std::enable_if_t<(Align > Size)>>
{
char dummy[Align - Size];
@ -104,10 +104,10 @@ namespace stx
};
template <typename T>
class alignas(T) shared_data<T[]> final : align_filler<sizeof(shared_counter) + sizeof(std::size_t), alignof(T)>
class alignas(T) shared_data<T[]> final : align_filler<sizeof(shared_counter) + sizeof(usz), alignof(T)>
{
public:
std::size_t m_count;
usz m_count;
shared_counter m_ctr;
@ -301,13 +301,13 @@ namespace stx
}
template <typename T, bool Init = true>
static std::enable_if_t<std::is_unbounded_array_v<T>, single_ptr<T>> make_single(std::size_t count) noexcept
static std::enable_if_t<std::is_unbounded_array_v<T>, single_ptr<T>> make_single(usz count) noexcept
{
static_assert(sizeof(shared_data<T>) - offsetof(shared_data<T>, m_ctr) == sizeof(shared_counter));
using etype = std::remove_extent_t<T>;
const std::size_t size = sizeof(shared_data<T>) + count * sizeof(etype);
const usz size = sizeof(shared_data<T>) + count * sizeof(etype);
std::byte* bytes = nullptr;
@ -535,7 +535,7 @@ namespace stx
}
}
std::size_t use_count() const noexcept
usz use_count() const noexcept
{
if (m_ptr)
{
@ -588,7 +588,7 @@ namespace stx
}
template <typename T, bool Init = true>
static std::enable_if_t<std::is_unbounded_array_v<T>, shared_ptr<T>> make_shared(std::size_t count) noexcept
static std::enable_if_t<std::is_unbounded_array_v<T>, shared_ptr<T>> make_shared(usz count) noexcept
{
return make_single<T, Init>(count);
}