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?
I'm trying to use
Finderto get a reference to an Element, and then accept a Visitor from this element, but I'm getting the following error:The problem is that
FinderreturnsElementInfowithconst svgdom::Element& einstead ofsvgdom::Element& e, so the Element can't be modified.Here's the code that is causing the error:
Using
Finderto 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?