[Lemon-user] Insert an element to a map without copying it.

B B blackbox.dev.ml at gmail.com
Wed Jun 5 13:51:22 CEST 2013


Hi! 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. ;)

Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20130605/6ec70c6c/attachment.html>


More information about the Lemon-user mailing list