Hello,
I have the following filter iterator working perfectly with gcc 4.7 and
4.9 as well (C++11 support)
But when I compile my code with intel compiler 13.0.1 version I get the
following error
error: *implicitly generated assignment operator cannot copy: reference
member* "my_func::G"
...
Details:
I am using a filtered_graph over Boost::adjacency_list as my graph type
(Graph_t). The vertex_iterator (from graph_traits .. provides
iterator range to iterate over graph vertices. I have to assign each graph
vertex an id (using property_maps) and group them together by applying
filter_iterator over
vertex iterator.
example: suppose I want to create 4 subgroups of vertices. So I create a
filter predicate which is passed to filter iterator which gives me
iterators satisfying the predicate.
For FOUR such groups, I get 4 pairs of filter iterators.
A vector stores such filter_iterator pairs.
std::vector < pair > my_vector
//stores iterator pair.
Here is the code:
vertex_iterator vbegin, vend;
boost::tie(vbegin, vend) = boost::vertices(G);
for (int i=0; i<4; ++i)
{
//for each i, create a filter_pred object
my_filter_pred <Graph> filter_pred(G, i)
//now create begin and end filter iterators as follows
auto fbegin = boost::make_filter_iterator< my_filter_pred<Graph>,
vertex_iterator>
(filter_pred, vbegin, vend)
auto fend = boost::make_filter_iterator< my_filter_pred<Graph>,
vertex_iterator>
(filter_pred, vend, vend)
//fbegin, fend are of type filter iterator
//insert the iterator pair into vector
my_vector.push_back( std::make_pair (fbegin, fend) );
}
The predicate is below :
template<typename Graph>
struct my_filter_pred {
public:
my_filter_pred() { }
my_filter_pred(Graph& _G, int _value) : G(_G), value(_value) { }
template<typename vertex_t>
bool operator() (vertex_t vertex) {
//get property "p" of vertex in graph G
auto p = get (mypropertytype, vertex, G);
return (p.val == value);
}
private:
Graph& G;
}
ERROR :
error: implicitly generated assignment operator cannot copy:
reference member "my_filter_pred <Graph>::G [with ... ]"
I tried to provide my own assignment operator as below:
my_filter_pred& operator=(const my_filter_pred& other) {
if (this != &other)
G = other.G;
return *this;
}
But it gave the same icpc error for actual typedef graph which is below
:
error: implicitly generated assignment operator cannot copy:
" implicit generation of boost::filtered_graph_base " ....
Please help what should I do in this case to work.
main motive : is to have a container which stores
pair which satisfies a predicate. Filter iterator was the best choice i
could have to apply different filter predicate to same vertex_iterator
range vbegin, vend;
Thanks
Aniket Pugaonkar
Aniket Pugaonkar