- more threading things

TODO: documentation
This commit is contained in:
2025-12-19 20:58:19 -05:00
parent 88e33bdcc8
commit 9f499c933d
12 changed files with 264 additions and 53 deletions

View File

@@ -25,6 +25,7 @@
namespace fennec::detail
{
template<typename TypeT> struct _add_pointer : type_identity<TypeT*> {};
template<typename TypeT> struct _add_pointer<TypeT&> : type_identity<TypeT*> {};
template<typename TypeT> struct _remove_pointer : type_identity<TypeT> {};
template<typename TypeT> struct _remove_pointer<TypeT*> : type_identity<TypeT> {};
@@ -43,36 +44,48 @@ namespace fennec::detail
template<typename TypeT> struct _remove_cv<const volatile TypeT> : type_identity<TypeT> {};
template<typename TypeT>
struct _decay : conditional<_is_const<const TypeT>{}, _remove_cv<TypeT>, _add_pointer<TypeT>> {};
struct _decay_selector : conditional_t<_is_const<const TypeT>{}, _remove_cv<TypeT>, _add_pointer<TypeT>> {};
template<typename TypeT> requires requires { typename TypeT::element_t; }
struct _decay<TypeT> : type_identity<typename TypeT::decay_t> {};
template<typename TypeT> requires requires { typename TypeT::decay_t; }
struct _decay_selector<TypeT> : type_identity<typename TypeT::decay_t> {};
template<typename TypeT, size_t N>
struct _decay<TypeT[N]> : type_identity<TypeT*> {};
struct _decay_selector<TypeT[N]> : type_identity<TypeT*> {};
template<typename TypeT>
struct _decay<TypeT[]> : type_identity<TypeT*> {};
struct _decay_selector<TypeT[]> : type_identity<TypeT*> {};
template<typename _Tp, typename = void>
template<typename TypeT> struct _decay {
using type = typename _decay_selector<TypeT>::type;
};
template<typename TypeT> struct _decay<TypeT&> {
using type = typename _decay_selector<TypeT>::type;
};
template<typename TypeT> struct _decay<TypeT&&> {
using type = typename _decay_selector<TypeT>::type;
};
template<typename TypeT, typename = void>
struct _add_lvalue_reference {
using type = _Tp;
using type = TypeT;
};
template<typename _Tp>
struct _add_lvalue_reference<_Tp, void_t<_Tp&>> {
using type = _Tp&;
template<typename TypeT>
struct _add_lvalue_reference<TypeT, void_t<TypeT&>> {
using type = TypeT&;
};
template<typename _Tp, typename = void>
template<typename TypeT, typename = void>
struct _add_rvalue_reference {
using type = _Tp;
using type = TypeT;
};
template<typename _Tp>
struct _add_rvalue_reference<_Tp, void_t<_Tp&&>> {
using type = _Tp&&;
template<typename TypeT>
struct _add_rvalue_reference<TypeT, void_t<TypeT&&>> {
using type = TypeT&&;
};
}

View File

@@ -53,7 +53,9 @@ class function<ReturnT(ArgsT...)> {
public:
///
/// \brief default constructor
constexpr function() noexcept = default;
constexpr function() noexcept
: call(nullptr) {
}
///
/// \brief destructor
@@ -62,7 +64,7 @@ public:
///
/// \brief copy constructor
/// \param func the function to copy
constexpr function(const function& func) noexcept = default;
constexpr function(const function& func) noexcept = default;
///
/// \brief move constructor

View File

@@ -84,6 +84,15 @@ template<typename T> constexpr T&& forward(remove_reference_t<T>&& x) noexcept {
#endif
/// \brief Copies \f$v\f$ to a new object of `decay_t<T>`
/// \tparam T The type
/// \param v The object
/// \returns A stack allocated copy of \f$v\f$ in `decay_t<T>`
template<typename T> constexpr decay_t<T> decay_copy(T&& v) {
return fennec::forward<T>(v);
}
///
/// \brief produces an x-value type to indicate \p x may be "moved"
///