Skip to content

Commit

Permalink
Use requires syntax in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekotekina committed Apr 19, 2021
1 parent 7dae376 commit f5f57ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 35 deletions.
3 changes: 1 addition & 2 deletions Utilities/Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,7 @@ class named_thread final : public Context, result_storage<Context>, thread_base

public:
// Default constructor
template <bool Valid = std::is_default_constructible_v<Context> && thread_thread_name<Context>(), typename = std::enable_if_t<Valid>>
named_thread()
named_thread() requires (std::is_default_constructible_v<Context>) && (thread_thread_name<Context>::value)
: Context()
, thread(trampoline, Context::thread_name)
{
Expand Down
44 changes: 11 additions & 33 deletions rpcs3/util/shared_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ namespace stx
atomic_t<usz> refs{1};
};

template <usz Size, usz Align, typename = void>
template <usz Size, usz Align>
struct align_filler
{
};

template <usz Size, usz Align>
struct align_filler<Size, Align, std::enable_if_t<(Align > Size)>>
template <usz Size, usz Align> requires (Align > Size)
struct align_filler<Size, Align>
{
char dummy[Align - Size];
};
Expand Down Expand Up @@ -236,30 +236,19 @@ namespace stx
return m_ptr;
}

decltype(auto) operator*() const noexcept
decltype(auto) operator*() const noexcept requires (!std::is_void_v<element_type>)
{
if constexpr (std::is_void_v<element_type>)
{
return;
}
else
{
return *m_ptr;
}
return *m_ptr;
}

element_type* operator->() const noexcept
{
return m_ptr;
}

decltype(auto) operator[](std::ptrdiff_t idx) const noexcept
decltype(auto) operator[](std::ptrdiff_t idx) const noexcept requires (!std::is_void_v<element_type>)
{
if constexpr (std::is_void_v<element_type>)
{
return;
}
else if constexpr (std::is_array_v<T>)
if constexpr (std::is_array_v<T>)
{
return m_ptr[idx];
}
Expand Down Expand Up @@ -572,30 +561,19 @@ namespace stx
return m_ptr;
}

decltype(auto) operator*() const noexcept
decltype(auto) operator*() const noexcept requires (!std::is_void_v<element_type>)
{
if constexpr (std::is_void_v<element_type>)
{
return;
}
else
{
return *m_ptr;
}
return *m_ptr;
}

element_type* operator->() const noexcept
{
return m_ptr;
}

decltype(auto) operator[](std::ptrdiff_t idx) const noexcept
decltype(auto) operator[](std::ptrdiff_t idx) const noexcept requires (!std::is_void_v<element_type>)
{
if constexpr (std::is_void_v<element_type>)
{
return;
}
else if constexpr (std::is_array_v<T>)
if constexpr (std::is_array_v<T>)
{
return m_ptr[idx];
}
Expand Down

0 comments on commit f5f57ee

Please sign in to comment.