Skip to content

Extend cetl::rtti_helper to support non-default constructor of the first base type. #111

@serges147

Description

@serges147

Currently, I have to write something like this to inherit from TestBase and have RTTI support:

struct TestCopyableOnly final : TestBase
{
    explicit TestCopyableOnly(const char payload) : TestBase(payload) { ... }
    // rtti
    static constexpr type_id _get_type_id_() noexcept { ... }
    CETL_NODISCARD void* _cast_(const type_id& id) & noexcept override { ... }
    CETL_NODISCARD const void* _cast_(const type_id& id) const& noexcept override { ... }

Ideally make it possible to write like this:

struct TestCopyableOnly final : rtti_helper<type_id_type<...>, TestBase>
{
    using base = rtti_helper<type_id_type<...>, TestBase>::base; // TBD
    explicit TestCopyableOnly(const char payload) : base(payload)) { ... }

Although, I'm not sure how it will better tune api of rtti_helper so that:

  1. easier make the using base = ... declaration (without duplicating type id!)
  2. support multiple inheritance (like struct DogCat : rtti_helper<type_id_type<...>, Dog, Cat> { ... }) while passing all (variadic?) arguments to at least the first base constructor (the Dog(some_args) one).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions