stl: std::constructible_from

This commit is contained in:
skypjack
2026-04-17 09:11:48 +02:00
parent 398a8c70a5
commit b5cd97f915
9 changed files with 17 additions and 16 deletions

View File

@@ -79,7 +79,7 @@ public:
: it{iter} {}
template<typename Other>
requires (!stl::same_as<It, Other> && std::constructible_from<It, Other>)
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr dense_map_iterator(const dense_map_iterator<Other> &other) noexcept
: it{other.it} {}
@@ -174,7 +174,7 @@ public:
offset{pos} {}
template<typename Other>
requires (!stl::same_as<It, Other> && std::constructible_from<It, Other>)
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr dense_map_local_iterator(const dense_map_local_iterator<Other> &other) noexcept
: it{other.it},
offset{other.offset} {}
@@ -534,7 +534,7 @@ public:
* @tparam Arg Type of the key-value pair to insert into the container.
*/
template<typename Arg>
requires std::constructible_from<value_type, Arg &&>
requires stl::constructible_from<value_type, Arg &&>
stl::pair<iterator, bool> insert(Arg &&value) {
return insert_or_do_nothing(stl::forward<Arg>(value).first, stl::forward<Arg>(value).second);
}

View File

@@ -48,7 +48,7 @@ public:
: it{iter} {}
template<typename Other>
requires (!stl::same_as<It, Other> && std::constructible_from<It, Other>)
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr dense_set_iterator(const dense_set_iterator<Other> &other) noexcept
: it{other.it} {}
@@ -140,7 +140,7 @@ public:
offset{pos} {}
template<typename Other>
requires (!stl::same_as<It, Other> && std::constructible_from<It, Other>)
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr dense_set_local_iterator(const dense_set_local_iterator<Other> &other) noexcept
: it{other.it},
offset{other.offset} {}

View File

@@ -35,7 +35,7 @@ public:
: it{from...} {}
template<typename... Other>
requires (std::constructible_from<It, Other> && ...)
requires (stl::constructible_from<It, Other> && ...)
constexpr table_iterator(const table_iterator<Other...> &other) noexcept
: table_iterator{stl::get<Other>(other.it)...} {}

View File

@@ -57,7 +57,7 @@ public:
: it{iter} {}
template<typename Other>
requires (!stl::same_as<It, Other> && std::constructible_from<It, Other>)
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr registry_storage_iterator(const registry_storage_iterator<Other> &other) noexcept
: registry_storage_iterator{other.it} {}

View File

@@ -152,7 +152,7 @@ public:
: it{base, other...} {}
template<typename... Args>
requires (!stl::same_as<Other, Args> && ...) && (std::constructible_from<Other, Args> && ...)
requires (!stl::same_as<Other, Args> && ...) && (stl::constructible_from<Other, Args> && ...)
constexpr extended_storage_iterator(const extended_storage_iterator<It, Args...> &other)
: it{other.it} {}

View File

@@ -86,7 +86,7 @@ public:
* @return A reference to a valid service.
*/
template<std::derived_from<Service> Type = Service, typename... Args>
requires std::constructible_from<Type, Args...>
requires stl::constructible_from<Type, Args...>
[[nodiscard]] static Service &value_or(Args &&...args) {
return service ? *service : emplace<Type>(stl::forward<Args>(args)...);
}
@@ -99,7 +99,7 @@ public:
* @return A reference to a valid service.
*/
template<std::derived_from<Service> Type = Service, typename... Args>
requires std::constructible_from<Type, Args...>
requires stl::constructible_from<Type, Args...>
static Service &emplace(Args &&...args) {
service = std::make_shared<Type>(stl::forward<Args>(args)...);
return *service;
@@ -114,7 +114,7 @@ public:
* @return A reference to a valid service.
*/
template<std::derived_from<Service> Type = Service, typename... Args>
requires std::constructible_from<Type, 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)...);
return *service;

View File

@@ -42,7 +42,7 @@ public:
: it{iter} {}
template<typename Other>
requires (!stl::same_as<It, Other> && std::constructible_from<It, Other>)
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr resource_cache_iterator(const resource_cache_iterator<stl::remove_const_t<Type>, Other> &other) noexcept
: it{other.it} {}

View File

@@ -63,7 +63,7 @@ public:
* @param other The handle to copy from.
*/
template<typename Other>
requires (!stl::same_as<Type, Other> && std::constructible_from<Type &, Other &>)
requires (!stl::same_as<Type, Other> && stl::constructible_from<Type &, Other &>)
resource(const resource<Other> &other) noexcept
: value{other.value} {}
@@ -73,7 +73,7 @@ public:
* @param other The handle to move from.
*/
template<typename Other>
requires (!stl::same_as<Type, Other> && std::constructible_from<Type &, Other &>)
requires (!stl::same_as<Type, Other> && stl::constructible_from<Type &, Other &>)
resource(resource<Other> &&other) noexcept
: value{stl::move(other.value)} {}
@@ -99,7 +99,7 @@ public:
* @return This resource handle.
*/
template<typename Other>
requires (!stl::same_as<Type, Other> && std::constructible_from<Type &, Other &>)
requires (!stl::same_as<Type, Other> && stl::constructible_from<Type &, Other &>)
resource &operator=(const resource<Other> &other) noexcept {
value = other.value;
return *this;
@@ -112,7 +112,7 @@ public:
* @return This resource handle.
*/
template<typename Other>
requires (!stl::same_as<Type, Other> && std::constructible_from<Type &, Other &>)
requires (!stl::same_as<Type, Other> && stl::constructible_from<Type &, Other &>)
resource &operator=(resource<Other> &&other) noexcept {
value = stl::move(other.value);
return *this;

View File

@@ -6,6 +6,7 @@
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::constructible_from;
using std::same_as;
} // namespace entt::stl