skypjack 2 дней назад
Родитель
Сommit
8f67d4fa06

+ 1 - 1
src/entt/container/dense_map.hpp

@@ -972,7 +972,7 @@ public:
 
             for(size_type pos{}, last = size(); pos < last; ++pos) {
                 const auto index = key_to_bucket(packed.first()[pos].element.first);
-                packed.first()[pos].next = std::exchange(sparse.first()[index], pos);
+                packed.first()[pos].next = stl::exchange(sparse.first()[index], pos);
             }
         }
     }

+ 1 - 1
src/entt/container/dense_set.hpp

@@ -848,7 +848,7 @@ public:
 
             for(size_type pos{}, last = size(); pos < last; ++pos) {
                 const auto index = value_to_bucket(packed.first()[pos].second);
-                packed.first()[pos].first = std::exchange(sparse.first()[index], pos);
+                packed.first()[pos].first = stl::exchange(sparse.first()[index], pos);
             }
         }
     }

+ 2 - 2
src/entt/core/any.hpp

@@ -250,7 +250,7 @@ public:
         if(other.mode == any_policy::embedded) {
             other.vtable(request::move, other, this);
         } else if(other.mode != any_policy::empty) {
-            this->instance = std::exchange(other.instance, nullptr);
+            this->instance = stl::exchange(other.instance, nullptr);
         }
     }
 
@@ -290,7 +290,7 @@ public:
             if(other.mode == any_policy::embedded) {
                 other.vtable(request::move, other, this);
             } else if(other.mode != any_policy::empty) {
-                this->instance = std::exchange(other.instance, nullptr);
+                this->instance = stl::exchange(other.instance, nullptr);
             }
 
             vtable = other.vtable;

+ 2 - 2
src/entt/entity/handle.hpp

@@ -173,7 +173,7 @@ public:
 
     /*! @brief Destroys the entity associated with a handle. */
     void destroy() {
-        owner_or_assert().destroy(std::exchange(entt, null));
+        owner_or_assert().destroy(stl::exchange(entt, null));
     }
 
     /**
@@ -181,7 +181,7 @@ public:
      * @param version A desired version upon destruction.
      */
     void destroy(const version_type version) {
-        owner_or_assert().destroy(std::exchange(entt, null), version);
+        owner_or_assert().destroy(stl::exchange(entt, null), version);
     }
 
     /**

+ 1 - 1
src/entt/entity/runtime_view.hpp

@@ -225,7 +225,7 @@ public:
         if(pools.empty() || !(base.size() < pools.front()->size())) {
             pools.push_back(&base);
         } else {
-            pools.push_back(std::exchange(pools.front(), &base));
+            pools.push_back(stl::exchange(pools.front(), &base));
         }
 
         return *this;

+ 9 - 9
src/entt/entity/sparse_set.hpp

@@ -260,8 +260,8 @@ protected:
      */
     void in_place_pop(const Entity entt) {
         ENTT_ASSERT(mode == deletion_policy::in_place, "Deletion policy mismatch");
-        const auto pos = entity_to_pos(std::exchange(sparse_ref(entt), null));
-        packed[pos] = traits_type::combine(static_cast<traits_type::entity_type>(std::exchange(head, pos)), tombstone);
+        const auto pos = entity_to_pos(stl::exchange(sparse_ref(entt), null));
+        packed[pos] = traits_type::combine(static_cast<traits_type::entity_type>(stl::exchange(head, pos)), tombstone);
     }
 
     /**
@@ -323,7 +323,7 @@ protected:
                 pos = head;
                 ENTT_ASSERT(elem == null, "Slot not available");
                 elem = traits_type::combine(static_cast<traits_type::entity_type>(head), traits_type::to_integral(entt));
-                head = entity_to_pos(std::exchange(packed[pos], entt));
+                head = entity_to_pos(stl::exchange(packed[pos], entt));
                 break;
             }
             [[fallthrough]];
@@ -422,7 +422,7 @@ public:
           packed{std::move(other.packed)},
           descriptor{other.descriptor},
           mode{other.mode},
-          head{std::exchange(other.head, policy_to_head())} {}
+          head{stl::exchange(other.head, policy_to_head())} {}
 
     /**
      * @brief Allocator-extended move constructor.
@@ -434,7 +434,7 @@ public:
           packed{std::move(other.packed), allocator},
           descriptor{other.descriptor},
           mode{other.mode},
-          head{std::exchange(other.head, policy_to_head())} {
+          head{stl::exchange(other.head, policy_to_head())} {
         ENTT_ASSERT(alloc_traits::is_always_equal::value || get_allocator() == other.get_allocator(), "Copying a sparse set is not allowed");
     }
 
@@ -540,7 +540,7 @@ public:
                         other.resize(sz, nullptr);
                     }
 
-                    other[page] = std::exchange(sparse[page], nullptr);
+                    other[page] = stl::exchange(sparse[page], nullptr);
 
                     if(++cnt == len) {
                         // early exit due to lack of pages
@@ -889,12 +889,12 @@ public:
     void compact() {
         if(mode == deletion_policy::in_place) {
             size_type from = packed.size();
-            size_type pos = std::exchange(head, max_size);
+            size_type pos = stl::exchange(head, max_size);
 
             for(; from && packed[from - 1u] == tombstone; --from) {}
 
             while(pos != max_size) {
-                if(const auto to = std::exchange(pos, entity_to_pos(packed[pos])); to < from) {
+                if(const auto to = stl::exchange(pos, entity_to_pos(packed[pos])); to < from) {
                     --from;
                     swap_or_move(from, to);
 
@@ -980,7 +980,7 @@ public:
                 swap_or_move(next, idx);
                 const auto elem = static_cast<traits_type::entity_type>(curr);
                 sparse_ref(entt) = traits_type::combine(elem, traits_type::to_integral(packed[curr]));
-                curr = std::exchange(next, idx);
+                curr = stl::exchange(next, idx);
             }
         }
     }

+ 1 - 1
src/entt/entity/storage.hpp

@@ -331,7 +331,7 @@ protected:
             } else {
                 auto &other = element_at(base_type::size() - 1u);
                 // destroying on exit allows reentrant destructors
-                [[maybe_unused]] auto unused = std::exchange(elem, std::move(other));
+                [[maybe_unused]] auto unused = stl::exchange(elem, std::move(other));
                 alloc_traits::destroy(allocator, std::addressof(other));
                 base_type::swap_and_pop(*first);
             }

+ 2 - 2
src/entt/graph/adjacency_matrix.hpp

@@ -289,7 +289,7 @@ public:
             matrix[rev] = 1u;
         }
 
-        const auto inserted = !std::exchange(matrix[pos], 1u);
+        const auto inserted = !stl::exchange(matrix[pos], 1u);
         return {edge_iterator{matrix.cbegin(), vert, pos, matrix.size(), 1u}, inserted};
     }
 
@@ -308,7 +308,7 @@ public:
             matrix[rev] = 0u;
         }
 
-        return std::exchange(matrix[pos], 0u);
+        return stl::exchange(matrix[pos], 0u);
     }
 
     /**

+ 8 - 8
src/entt/meta/meta.hpp

@@ -326,8 +326,8 @@ public:
     meta_any(const meta_ctx &area, meta_any &&other)
         : storage{std::move(other.storage)},
           ctx{&area},
-          node{(ctx == other.ctx) ? std::exchange(other.node, nullptr) : nullptr},
-          vtable{std::exchange(other.vtable, nullptr)} {}
+          node{(ctx == other.ctx) ? stl::exchange(other.node, nullptr) : nullptr},
+          vtable{stl::exchange(other.vtable, nullptr)} {}
 
     /**
      * @brief Copy constructor.
@@ -347,8 +347,8 @@ public:
     meta_any(meta_any &&other) noexcept
         : storage{std::move(other.storage)},
           ctx{other.ctx},
-          node{std::exchange(other.node, nullptr)},
-          vtable{std::exchange(other.vtable, nullptr)} {}
+          node{stl::exchange(other.node, nullptr)},
+          vtable{stl::exchange(other.vtable, nullptr)} {}
 
     /*! @brief Default destructor. */
     ~meta_any() = default;
@@ -377,8 +377,8 @@ public:
     meta_any &operator=(meta_any &&other) noexcept {
         storage = std::move(other.storage);
         ctx = other.ctx;
-        node = std::exchange(other.node, nullptr);
-        vtable = std::exchange(other.vtable, nullptr);
+        node = stl::exchange(other.node, nullptr);
+        vtable = stl::exchange(other.vtable, nullptr);
         return *this;
     }
 
@@ -551,7 +551,7 @@ public:
     template<typename Type, typename... Args>
     void emplace(Args &&...args) {
         storage.emplace<Type>(std::forward<Args>(args)...);
-        auto *prev = std::exchange(vtable, &basic_vtable<stl::remove_cvref_t<Type>>);
+        auto *prev = stl::exchange(vtable, &basic_vtable<stl::remove_cvref_t<Type>>);
         node = (prev == vtable) ? node : nullptr;
     }
 
@@ -1424,7 +1424,7 @@ public:
 
         if(const auto &ref = fetch_node(); ref.details) {
             if(auto *elem = internal::find_member(ref.details->func, id); elem != nullptr) {
-                if(const auto *candidate = lookup(args, sz, (wrapped->base().policy() == any_policy::cref), [curr = elem]() mutable { return (curr != nullptr) ? std::exchange(curr, curr->next.get()) : nullptr; }); candidate) {
+                if(const auto *candidate = lookup(args, sz, (wrapped->base().policy() == any_policy::cref), [curr = elem]() mutable { return (curr != nullptr) ? stl::exchange(curr, curr->next.get()) : nullptr; }); candidate) {
                     return candidate->invoke(std::move(wrapped), args);
                 }
             }

+ 2 - 2
src/entt/signal/sigh.hpp

@@ -285,7 +285,7 @@ struct scoped_connection {
      * @param other The scoped connection to move from.
      */
     scoped_connection(scoped_connection &&other) noexcept
-        : conn{std::exchange(other.conn, {})} {}
+        : conn{stl::exchange(other.conn, {})} {}
 
     /*! @brief Automatically breaks the link on destruction. */
     ~scoped_connection() {
@@ -304,7 +304,7 @@ struct scoped_connection {
      * @return This scoped connection.
      */
     scoped_connection &operator=(scoped_connection &&other) noexcept {
-        conn = std::exchange(other.conn, {});
+        conn = stl::exchange(other.conn, {});
         return *this;
     }
 

+ 2 - 0
src/entt/stl/utility.hpp

@@ -6,6 +6,8 @@
 /*! @cond ENTT_INTERNAL */
 namespace entt::stl {
 
+using std::exchange;
+
 } // namespace entt::stl
 /*! @endcond */