Function propagate_on_container_swap

Synopsis

#include <src/entt/core/memory.hpp>

template <typename Allocator>
constexpr void propagate_on_container_swap([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs)

Description

Utility function to design allocation-aware containers.

Template Parameters

Allocator - Type of allocator.

Parameters

lhs - A valid allocator.

rhs - Another valid allocator.

Source

Lines 61-69 in src/entt/core/memory.hpp.

template<typename Allocator>
constexpr void propagate_on_container_swap([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) ENTT_NOEXCEPT {
    ENTT_ASSERT(std::allocator_traits<Allocator>::propagate_on_container_swap::value || lhs == rhs, "Cannot swap the containers");

    if constexpr(std::allocator_traits<Allocator>::propagate_on_container_swap::value) {
        using std::swap;
        swap(lhs, rhs);
    }
}





Add Discussion

Log in to comment