Pergunta

I'm using Lemon Graph Library and I want to add an item to a lemon map without copying it or asigning. Here is the code:

#include <iostream>
#include <lemon/list_graph.h>
#include <lemon/maps.h>

using namespace lemon;
using namespace std;

typedef lemon::ListDigraph             LGraph;
typedef lemon::ListDigraph::Arc        LArc;
typedef lemon::ListDigraph::Node       LNode;

class MyNode {
public:
    CrossRefMap<LGraph, LArc, std::string> inputs;

    MyNode(const LGraph& graph) : inputs(graph) { }
};


int main(){
    LGraph graph;
    LGraph::NodeMap<MyNode> nodes(graph);

    LNode n = graph.addNode();
    nodes[n] = MyNode(graph); // error: object of type 'MyNode' cannot be assigned because its copy assignment operator is implicitly deleted

    return 0;
}

The main problem here is the CrossRefMap which needs initialization in constructor and has has no copy consturctor or assignment operator. I could use pointer to this structure instead, but this solution doesn't satisfy me. How can I solve this problem? Any suggestions will be appreciated. ;)

Foi útil?

Solução

As far as I know there is no possibility to do it with standard lemon maps, so I implemented my own one based on std::map. I can track changes in the graph and update my map using lemon graph observers.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top