stl: std::derived_from

This commit is contained in:
skypjack
2026-04-17 09:13:18 +02:00
parent 080966ad8f
commit 750b450cd2
9 changed files with 17 additions and 16 deletions

View File

@@ -646,7 +646,7 @@ public:
* @param other The storage for the type to combine the view with.
* @return A more specific view.
*/
template<std::derived_from<common_type> OGet>
template<stl::derived_from<common_type> OGet>
[[nodiscard]] basic_view<get_t<Get..., OGet>, exclude_t<Exclude...>> operator|(OGet &other) const noexcept {
return *this | basic_view<get_t<OGet>, exclude_t<>>{other};
}
@@ -658,7 +658,7 @@ public:
* @param other The view to combine with.
* @return A more specific view.
*/
template<std::derived_from<common_type>... OGet, std::derived_from<common_type>... OExclude>
template<stl::derived_from<common_type>... OGet, stl::derived_from<common_type>... OExclude>
[[nodiscard]] auto operator|(const basic_view<get_t<OGet...>, exclude_t<OExclude...>> &other) const noexcept {
return internal::view_pack<basic_view<get_t<Get..., OGet...>, exclude_t<Exclude..., OExclude...>>>(
*this, other, stl::index_sequence_for<Get...>{}, stl::index_sequence_for<Exclude...>{}, stl::index_sequence_for<OGet...>{}, stl::index_sequence_for<OExclude...>{});
@@ -1102,7 +1102,7 @@ public:
* @param other The storage for the type to combine the view with.
* @return A more specific view.
*/
template<std::derived_from<common_type> OGet>
template<stl::derived_from<common_type> OGet>
[[nodiscard]] basic_view<get_t<Get, OGet>, exclude_t<>> operator|(OGet &other) const noexcept {
return *this | basic_view<get_t<OGet>, exclude_t<>>{other};
}
@@ -1114,7 +1114,7 @@ public:
* @param other The view to combine with.
* @return A more specific view.
*/
template<std::derived_from<common_type>... OGet, std::derived_from<common_type>... OExclude>
template<stl::derived_from<common_type>... OGet, stl::derived_from<common_type>... OExclude>
[[nodiscard]] auto operator|(const basic_view<get_t<OGet...>, exclude_t<OExclude...>> &other) const noexcept {
return internal::view_pack<basic_view<get_t<Get, OGet...>, exclude_t<OExclude...>>>(
*this, other, stl::index_sequence_for<Get>{}, stl::index_sequence_for<>{}, stl::index_sequence_for<OGet...>{}, stl::index_sequence_for<OExclude...>{});

View File

@@ -84,7 +84,7 @@ private:
* @tparam Category Either a directed or undirected category tag.
* @tparam Allocator Type of allocator used to manage memory and elements.
*/
template<std::derived_from<directed_tag> Category, typename Allocator>
template<stl::derived_from<directed_tag> Category, typename Allocator>
class adjacency_matrix {
using alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, stl::size_t>, "Invalid value type");

View File

@@ -15,7 +15,7 @@ namespace entt {
* @param writer Vertex decorator object.
*/
template<typename Graph>
requires std::derived_from<typename Graph::graph_category, directed_tag>
requires stl::derived_from<typename Graph::graph_category, directed_tag>
void dot(std::ostream &out, const Graph &graph, std::invocable<std::ostream &, typename Graph::vertex_type> auto writer) {
if constexpr(stl::same_as<typename Graph::graph_category, undirected_tag>) {
out << "graph{";

View File

@@ -14,7 +14,7 @@ struct directed_tag {};
/*! @brief Directed graph category tag. */
struct undirected_tag: directed_tag {};
template<std::derived_from<directed_tag>, typename = stl::allocator<stl::size_t>>
template<stl::derived_from<directed_tag>, typename = stl::allocator<stl::size_t>>
class adjacency_matrix;
template<typename = stl::allocator<id_type>>

View File

@@ -85,7 +85,7 @@ public:
* @param args Parameters to use to construct the fallback service.
* @return A reference to a valid service.
*/
template<std::derived_from<Service> Type = Service, typename... Args>
template<stl::derived_from<Service> Type = Service, typename... Args>
requires stl::constructible_from<Type, Args...>
[[nodiscard]] static Service &value_or(Args &&...args) {
return service ? *service : emplace<Type>(stl::forward<Args>(args)...);
@@ -98,7 +98,7 @@ public:
* @param args Parameters to use to construct the service.
* @return A reference to a valid service.
*/
template<std::derived_from<Service> Type = Service, typename... Args>
template<stl::derived_from<Service> Type = Service, typename... Args>
requires stl::constructible_from<Type, Args...>
static Service &emplace(Args &&...args) {
service = std::make_shared<Type>(stl::forward<Args>(args)...);
@@ -113,7 +113,7 @@ public:
* @param args Parameters to use to construct the service.
* @return A reference to a valid service.
*/
template<std::derived_from<Service> Type = Service, typename... Args>
template<stl::derived_from<Service> Type = Service, typename... Args>
requires stl::constructible_from<Type, Args...>
static Service &emplace(stl::allocator_arg_t, auto alloc, Args &&...args) {
service = std::allocate_shared<Type>(alloc, stl::forward<Args>(args)...);
@@ -145,7 +145,7 @@ public:
* @param elem A pointer to a service to manage.
* @param deleter A deleter to use to destroy the service.
*/
template<std::derived_from<Service> Type, typename Deleter = std::default_delete<Type>>
template<stl::derived_from<Service> Type, typename Deleter = std::default_delete<Type>>
static void reset(Type *elem, Deleter deleter = {}) {
service = stl::shared_ptr<Service>{elem, stl::move(deleter)};
}

View File

@@ -208,7 +208,7 @@ public:
* @return A meta factory for the parent type.
*/
template<typename Base>
requires std::derived_from<Type, Base>
requires stl::derived_from<Type, Base>
meta_factory base() noexcept {
if constexpr(!stl::same_as<Type, Base>) {
auto *const op = +[](const void *instance) noexcept { return static_cast<const void *>(static_cast<const Base *>(static_cast<const Type *>(instance))); };

View File

@@ -50,7 +50,7 @@ class poly_vtable {
using inspector = Concept::template type<poly_inspector>;
template<typename Ret, typename Clazz, typename... Args>
requires std::derived_from<inspector, stl::remove_const_t<Clazz>>
requires stl::derived_from<inspector, stl::remove_const_t<Clazz>>
static auto vtable_entry(Ret (*)(Clazz &, Args...))
-> Ret (*)(constness_as_t<basic_any<Len, Align>, Clazz> &, Args...);
@@ -59,12 +59,12 @@ class poly_vtable {
-> Ret (*)(const basic_any<Len, Align> &, Args...);
template<typename Ret, typename Clazz, typename... Args>
requires std::derived_from<inspector, Clazz>
requires stl::derived_from<inspector, Clazz>
static auto vtable_entry(Ret (Clazz::*)(Args...))
-> Ret (*)(basic_any<Len, Align> &, Args...);
template<typename Ret, typename Clazz, typename... Args>
requires std::derived_from<inspector, Clazz>
requires stl::derived_from<inspector, Clazz>
static auto vtable_entry(Ret (Clazz::*)(Args...) const)
-> Ret (*)(const basic_any<Len, Align> &, Args...);

View File

@@ -7,6 +7,7 @@
namespace entt::stl {
using std::constructible_from;
using std::derived_from;
using std::same_as;
} // namespace entt::stl

View File

@@ -61,7 +61,7 @@ struct iterator_tag<It> {
};
template<typename It, typename Tag>
concept has_iterator_tag = std::derived_from<typename iterator_tag<It>::type, Tag>;
concept has_iterator_tag = stl::derived_from<typename iterator_tag<It>::type, Tag>;
} // namespace internal