Skip to content

rfl::Variant not working with "Move-Only" types #184

@Urfoex

Description

@Urfoex

A move-only type with const fields, e.g. like this

struct OnlyMoveable{
    OnlyMoveable() = default;
    ~OnlyMoveable() = default;
    OnlyMoveable(OnlyMoveable &&) = default;

    OnlyMoveable(OnlyMoveable const &) = delete;
    auto operator=(OnlyMoveable const &) -> OnlyMoveable& = delete;
    auto operator=(OnlyMoveable &&) -> OnlyMoveable& = delete;

    bool const False = false;
};

gives an error because of move-assignment not being possible

/include/rfl/Variant.hpp:339:15: error: use of deleted function ‘std::optional<containers::ColumnView<double> >& std::optional<containers::ColumnView<double> >::operator=(std::optional<containers::ColumnView<double> >&&)’                                                                                           
  339 |         *_res = _f(get_alternative<_i>());                                                                                                                             

https://github.com/getml/reflect-cpp/blob/main/include/rfl/Variant.hpp#L339C1-L339C43

Maybe swap ? https://en.cppreference.com/w/cpp/utility/optional/swap

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions