#1302·entt

Process/scheduler fails to compile when using std::pmr::polymorphic_allocator

Author: coldcola233Created Dec 10, 2025Updated Jun 9, 2026
Labelsenhancement

EnTT version: 3.16.0

cpp
#include <entt/entt.hpp>
#include <memory_resource>

template<class Delta, class Allocator>
struct MyProcess : entt::basic_process<Delta, Allocator> {
    using process_type = entt::basic_process<Delta, Allocator>;
    using allocator_type = typename process_type::allocator_type;
    using delta_type   = typename process_type::delta_type;

    MyProcess(const allocator_type &alloc, delta_type delay)
        : process_type{alloc}, remaining{delay} {}

    void update(delta_type d, void*) override {
        remaining -= d;
        if (remaining <= delta_type{0}) this->succeed();
    }
private:
    delta_type remaining;
};

using Sched = entt::basic_scheduler<float, std::pmr::polymorphic_allocator<void>>;
using Proc  = MyProcess<float, std::pmr::polymorphic_allocator<void>>;

int main() {
    std::pmr::unsynchronized_pool_resource pool;
    std::pmr::polymorphic_allocator<void> alloc{&pool};
    Sched sched{alloc};
    sched.attach<Proc>(1.0f);   // <-- error here
}

The method attach is implemented as:

cpp
    template<typename Type, typename... Args>
    type &attach(Args &&...args) {
        const auto &allocator = handlers.second();
        return *handlers.first().emplace_back(std::allocate_shared<Type>(allocator, allocator, std::forward<Args>(args)...));
    }

MyProcess satisfies std::uses_allocator_v, so std::allocate_shared will attempt to propagate std::pmr::polymorphic_allocator<void>. But it failed.