Skip to content

Finder returns ElementInfo with const Element #30

@JaimeIvanCervantes

Description

@JaimeIvanCervantes

I'm trying to use Finder to get a reference to an Element, and then accept a Visitor from this element, but I'm getting the following error:

candidate function not viable: 'this' argument has type 'const svgdom::Element', but method is not marked const

The problem is that Finder returns ElementInfo with const svgdom::Element& e instead of svgdom::Element& e, so the Element can't be modified.

Here's the code that is causing the error:

auto ref = finder.findById(e.getLocalIdFromIri());
if (!ref) {
     return;
}

class MyVisitor : public Visitor {
public:
   virtual void defaultVisit(Element& e) override {
      // Modify Element here
   }
} myVisitor;

ref->e.accept(myVisitor);

Using Finder to modify Elements seems like a useful pattern to me, otherwise I would have to write my own implementation of Finder with non-constant Element, what do you think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions