Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use inheritance if there are no fields involved? #297

Open
Lazrius opened this issue Dec 17, 2024 · 1 comment
Open

Is it possible to use inheritance if there are no fields involved? #297

Lazrius opened this issue Dec 17, 2024 · 1 comment

Comments

@Lazrius
Copy link
Contributor

Lazrius commented Dec 17, 2024

Good afternoon.

I was wondering if it is possible to allow some form of inheritance if fields are not involved. I have the following example code:

// BaseConfig<T> provides a Load and Save functions for easy reusability / pre-processing before calling rfl functions
struct PatchNoteConfig : BaseConfig<PatchNoteConfig>
{
    PatchNoteConfig() : BaseConfig("patch_notes.yml", false) {}

    std::string url = "http://localhost:8080/notes.md";
    bool sortPatchNotes = true;
};

In this example, BaseConfig simply defines some functions for some code reuse, but it contains no fields directly. I assume that this fails due to the std::is_aggregate_v call failing, but I imagine that if read_struct was called, it would probably work? Would it be possible for us to reflect on structs that have no fields and a parameterless constructor?

@liuzicheng1987
Copy link
Contributor

It is.

The catch is that it is deactivated by default, because it increases compile time:

https://rfl.getml.com/c_arrays_and_inheritance/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants