|
Boost Users : |
Subject: [Boost-users] Compiler error when using property map get()
From: Trevor Harmon (Trevor.W.Harmon_at_[hidden])
Date: 2010-07-02 19:41:23
Hi,
The get() function for property maps has me puzzled. Calling it in one
context gives a compiler error, while in another context it does not.
A trivial example is below. Note that the code in foo() and main() are
identical. Any guesses as to why the foo() version gives a compiler
error while the main() version does not?
FWIW, the error is:
subgraph.cpp: In member function virtual void MyGraph::foo():
subgraph.cpp:15: error: conversion from
boost::subgraph_global_property_map<Subgraph*,
boost::adj_list_edge_property_map<boost::bidirectional_tag, size_t,
size_t&, size_t, boost::property<boost::edge_index_t, size_t,
boost::no_property>, boost::edge_index_t>, boost::edge_index_t> to
non-scalar type
boost::adj_list_edge_property_map<boost::bidirectional_tag, size_t,
size_t&, size_t, boost::property<boost::edge_index_t, size_t,
boost::no_property>, boost::edge_index_t> requested
Thanks,
Trevor
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/subgraph.hpp>
using namespace boost;
typedef subgraph<adjacency_list<vecS, vecS, bidirectionalS, int,
property<edge_index_t, std::size_t> > > Subgraph;
typedef property_map<Subgraph, edge_index_t>::type EdgeIndexMap;
class MyGraph : public Subgraph {
virtual void foo();
};
void MyGraph::foo() {
Subgraph g;
EdgeIndexMap edgeMap = get(edge_index, g);
}
int main(int, char**) {
Subgraph g;
EdgeIndexMap edgeMap = get(edge_index, g);
return 0;
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net