Skip to content

rfl::visit error: cannot bind non-const lvalue reference of type ‘int&’ to an rvalue of type ‘int‘ #187

@Urfoex

Description

@Urfoex
/include/containers/Column.hpp:244:22: error: cannot bind non-const lvalue reference of type ‘int&’ to an rvalue of type ‘int244 |     return rfl::visit(get, data_ptr_);
      |            ~~~~~~~~~~^~~~~~~~~~~~~~~~

https://github.com/getml/getml-community/blob/main/src/engine/include/containers/Column.hpp#L243

With std::visit it was possible to return lvalue references, e.g.:

  T &operator[](const T2 _i) {
    const auto get = [_i](auto &&_ptr) -> T & { return (*_ptr)[_i]; };
    return std::visit(get, data_ptr_);
  }

rfl::visit seems to not support that, as it is returning an rvalue via move:
e.g. https://github.com/getml/reflect-cpp/blob/main/include/rfl/Variant.hpp#L161

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