|
Boost Users : |
From: Shufei Fan (fansf_at_[hidden])
Date: 2007-04-16 17:26:03
Stephan Diederich <stephan.diederich <at> googlemail.com> writes:
> > Are you saying initialize the property-pointer in the class GA's
constructor?
>
> I just wanted to get a working example ;)
>
> > I tried this, I am on windows vc2003.net, but that still doesnot compile.
I've
> > switched to using local variable instead(although more local definitions,
but
> > easier to get it work anyway)
>
> Maybe we can get Doug (the one who made the Bundled Properties) to
> comment on this...
>
> Cheers,
> Stephan
>
Simplified sample as follows, produced the error.
#include <boost/config.hpp>
#include <iostream> // for std::cout
#include <fstream> // for std::cout
#include <utility> // for std::pair
#include <algorithm> // for std::for_each
#include <boost/utility.hpp> // for boost::tie
#include <boost/graph/graph_traits.hpp> // for boost::graph_traits
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphviz.hpp>
using namespace boost;
struct Node
{
int count;//pixel number for this region
double mode[3];//region mode (RGB)
};
struct Edge
{
double eWeight;//normalized number of common boundary
points
};
//For accessing mode[3]:
//pointer to Node-Mode
//new specialization of property_map for bundles with arrays
namespace boost{
template <typename Graph, typename T, typename Bundle, unsigned int Size>
struct property_map<Graph, T (Bundle::*) [Size]>
{
private:
typedef graph_traits<Graph> traits;
typedef typename Graph::vertex_bundled vertex_bundled;
typedef typename Graph::edge_bundled edge_bundled;
typedef typename mpl::if_c<(detail::is_vertex_bundle<vertex_bundled,
edge_bundled, Bundle>::value),
typename traits::vertex_descriptor,
typename traits::edge_descriptor>::type
descriptor;
typedef typename mpl::if_c<(detail::is_vertex_bundle<vertex_bundled,
edge_bundled, Bundle>::value),
vertex_bundled,
edge_bundled>::type
actual_bundle;
public:
typedef bundle_property_map<Graph, descriptor, actual_bundle, T
[Size]> type;
typedef bundle_property_map<const Graph, descriptor, actual_bundle, const T
[Size]>
const_type;
};
};
typedef boost::adjacency_list<
boost::listS, boost::listS, boost::bidirectionalS,
boost::property<vertex_index_t, int, Node>, Edge> Graph;
class GA {
//data members
//Number of points
int nRowPnt;
int nColPnt;
//Graph variables
Graph *rowGraph;
Graph *colGraph;
boost::property_map<Graph, vertex_index_t>::type L_vertex_id,
R_vertex_id;
boost::property_map<Graph, int Node::*>::type nmt;
//methods members
public:
//default constructor
GA():
nRowPnt (0),
nColPnt (0),
rowGraph(NULL),
colGraph(NULL)
{
rowGraph = new Graph();
colGraph = new Graph();
nmt = get(&Node::count, *rowGraph);
}
~GA()
{
delete rowGraph;
delete colGraph;
}
};
int main()
{
GA ga;
return 0;
}
///////////////////////////////////////////////////////////////////////////////
error:
xxxx...error C2512: 'boost::bundle_property_map<Graph,Descriptor,Bundle,T>' :
no appropriate default constructor available
with
[
Graph=Graph,
Descriptor=boost::property_map<Graph,int Node::* >::descriptor,
Bundle=Node,
T=int
]
xxxxxxxxxxx............................
try1 - 1 error(s), 0 warning(s)
Thanks,
Shufei
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