container: less sfinae, more concepts

This commit is contained in:
skypjack
2026-02-02 13:59:13 +01:00
parent 7d2321efde
commit efe67a700d
3 changed files with 11 additions and 6 deletions

View File

@@ -81,7 +81,8 @@ public:
constexpr dense_map_iterator(const It iter) noexcept
: it{iter} {}
template<typename Other, typename = std::enable_if_t<!std::is_same_v<It, Other> && std::is_constructible_v<It, Other>>>
template<typename Other>
requires !std::same_as<It, Other> && std::constructible_from<It, Other>
constexpr dense_map_iterator(const dense_map_iterator<Other> &other) noexcept
: it{other.it} {}
@@ -175,7 +176,8 @@ public:
: it{iter},
offset{pos} {}
template<typename Other, typename = std::enable_if_t<!std::is_same_v<It, Other> && std::is_constructible_v<It, Other>>>
template<typename Other>
requires !std::same_as<It, Other> && std::constructible_from<It, Other>
constexpr dense_map_local_iterator(const dense_map_local_iterator<Other> &other) noexcept
: it{other.it},
offset{other.offset} {}

View File

@@ -48,7 +48,8 @@ public:
constexpr dense_set_iterator(const It iter) noexcept
: it{iter} {}
template<typename Other, typename = std::enable_if_t<!std::is_same_v<It, Other> && std::is_constructible_v<It, Other>>>
template<typename Other>
requires !std::same_as<It, Other> && std::constructible_from<It, Other>
constexpr dense_set_iterator(const dense_set_iterator<Other> &other) noexcept
: it{other.it} {}
@@ -139,7 +140,8 @@ public:
: it{iter},
offset{pos} {}
template<typename Other, typename = std::enable_if_t<!std::is_same_v<It, Other> && std::is_constructible_v<It, Other>>>
template<typename Other>
requires !std::same_as<It, Other> && std::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

@@ -1,10 +1,10 @@
#ifndef ENTT_CONTAINER_TABLE_HPP
#define ENTT_CONTAINER_TABLE_HPP
#include <concepts>
#include <cstddef>
#include <iterator>
#include <tuple>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../core/iterator.hpp"
@@ -34,7 +34,8 @@ public:
constexpr table_iterator(It... from) noexcept
: it{from...} {}
template<typename... Other, typename = std::enable_if_t<(std::is_constructible_v<It, Other> && ...)>>
template<typename... Other>
requires (std::constructible_from<It, Other> && ...)
constexpr table_iterator(const table_iterator<Other...> &other) noexcept
: table_iterator{std::get<Other>(other.it)...} {}