Skip to content

Add memory_resource diagnostics interface #176

Description

@thirtytwobits

It's common for applications to maintain metrics for custom memory_resources. We should define a common interface that uses rtti allowing generic code to see if a given resource supports diagnostics and to obtain them.

Difficulties here include how to go from non-rtti pmr::memory_resource to the diagnostics interface type.

Activity

  1. pavel-kirienko commented on Mar 7, 2025

    @pavel-kirienko
    Member

    Difficulties here include how to go from non-rtti pmr::memory_resource to the diagnostics interface type.

    This use case is supported in cetl::rtti via specializations of type_id_getter():

    /// The type ID getter for the given type.
    /// This helper is provided for regularity; it returns the same value as \c T::_get_type_id_().
    /// The type shall satisfy \ref cetl::has_type_id.
    /// Specialize this getter to add RTTI support to types where it is not possible to define a static method
    /// (e.g., builtins, pointers, third-party classes, etc).
    template <typename T>
    constexpr type_id type_id_getter() noexcept
    {
    return T::_get_type_id_();
    }

    So we just specialize it for pmr::memory_resource and we're done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions