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

Open
#111 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp
Domain
tooling

Research direction

Start at cetl::rtti_helper and trace its current base-type and constructor behavior. Compare the requested TestCopyableOnly and DogCat forms, then define acceptance checks for forwarding arguments to the first base, supporting multiple inheritance, and avoiding duplicated type IDs. No file or test path is named in the issue.

Written by the indexing model from the issue text.

Description

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).
Dominant language
C++
Stars
18
Forks
4
Avg merge
7d 16h
Merged PRs (30d)
7

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenCyphal/CETL

All issues in OpenCyphal/CETL

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.