|
Boost Users : |
From: Dmitry Bufistov (dmitry_at_[hidden])
Date: 2006-02-14 09:08:19
Hi all,
I'm trying to compile the following code and have some compiler errors
(MSVC 8).
// TestBoostGraph1.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/adjacency_matrix.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/graph/copy.hpp> ///Just for read "work around"
///Two typedefs for modeling both "discrete" & "continues" nets
typedef int discret_net_t;
typedef double continues_net_t;
///
typedef enum {PLACE, TRANSITION} node_type_t;
/*!
* If you need some more properties, then you should define your
property class that derived from
* basic_vertex_properties<>; - for nodes,
* basic_edge_properties<>; - for edges
* Example:
struct my_node_prop : basic_vertex_properties<discret_net_t> {
typedef double node_delay_t;
node_delay_t m_node_delay;
};
typedef CPetriNet<adj_list, boost::vecS, boost::listS,
boost::bidirectionalS, my_node_prop> petri_net_t
*
* The types of all property values must be Copy Constructible,
Assignable and Default Constructible!!
*/
template <class T = discret_net_t> struct basic_vertex_properties {
typedef std::string node_name_type;
typedef int node_index_t;
basic_vertex_properties(node_type_t nt = TRANSITION) :
m_node_type(nt) { m_token_number = T(0);}
T m_token_number; ///Only for place, possible costruct
"continues" nets
node_name_type m_node_name;
node_type_t m_node_type; ///Vertex could be "Place" or "transition"
node_index_t m_node_index;///Internal property for convenient
vertices lookup
};
///Basic properties for edge
template <class T = discret_net_t> struct basic_edge_properties {
typedef int edge_index_t;
basic_edge_properties(T ew = 0) : m_weight(ew) {}
T m_weight; ///possible construct "continues" nets
edge_index_t m_edge_index; ///Internal property for convenient
vertices lookup;
};
using boost::bidirectionalS;
using boost::directedS;
using boost::no_property;
struct my_ver_p : public basic_vertex_properties<discret_net_t>
{
double m_node_delay;
};
struct my_edge_p : public basic_edge_properties<discret_net_t>
{
double m_edge_delay;
};
int _tmain(int argc, _TCHAR* argv[])
{
typedef boost::adjacency_list<boost::listS, boost::listS,
directedS, my_ver_p> adj_list1_t;
adj_list1_t c(10);
boost::property_map<adj_list1_t, my_ver_p::node_name_type
my_ver_p::* >::type
node_name_map1(boost::get(&my_ver_p::m_node_name, c));
boost::print_graph(c, node_name_map1) ;
return 0;
}
1>------ Build started: Project: TestBoostGraph1, Configuration: Debug
Win32 ------
1>Compiling...
1>TestBoostGraph1.cpp
1>d:\documents and settings\dmitry\my documents\visual studio
2005\projects\testboostgraph1\testboostgraph1\testboostgraph1.cpp(78) :
error C2664:
'boost::bundle_property_map<Graph,Descriptor,Bundle,T>::bundle_property_map(const
boost::bundle_property_map<Graph,Descriptor,Bundle,T> &)' : cannot
convert parameter 1 from
'boost::bundle_property_map<Graph,Descriptor,Bundle,T>' to 'const
boost::bundle_property_map<Graph,Descriptor,Bundle,T> &'
1> with
1> [
1> Graph=adj_list1_t,
1> Descriptor=void *,
1> Bundle=my_ver_p,
1> T=basic_vertex_properties<discret_net_t>::node_name_type
1> ]
1> and
1> [
1>
Graph=boost::adjacency_list<boost::listS,boost::listS,boost::directedS,my_ver_p>,
1>
Descriptor=boost::detail::edge_desc_impl<boost::directed_tag,void *>,
1> Bundle=basic_vertex_properties<discret_net_t>,
1> T=basic_vertex_properties<discret_net_t>::node_name_type
1> ]
1> and
1> [
1> Graph=adj_list1_t,
1> Descriptor=void *,
1> Bundle=my_ver_p,
1> T=basic_vertex_properties<discret_net_t>::node_name_type
1> ]
1> Reason: cannot convert from
'boost::bundle_property_map<Graph,Descriptor,Bundle,T>' to 'const
boost::bundle_property_map<Graph,Descriptor,Bundle,T>'
1> with
1> [
1>
Graph=boost::adjacency_list<boost::listS,boost::listS,boost::directedS,my_ver_p>,
1>
Descriptor=boost::detail::edge_desc_impl<boost::directed_tag,void *>,
1> Bundle=basic_vertex_properties<discret_net_t>,
1> T=basic_vertex_properties<discret_net_t>::node_name_type
1> ]
1> and
1> [
1> Graph=adj_list1_t,
1> Descriptor=void *,
1> Bundle=my_ver_p,
1> T=basic_vertex_properties<discret_net_t>::node_name_type
1> ]
1> No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called
1>TestBoostGraph1 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
if change graph representation to following
typedef boost::adjacency_list<boost::listS, boost::listS, directedS,
basic_vertex_properties<> > adj_list1_t;
then this compiles without any error:
adj_list1_t c(10);
boost::property_map<adj_list1_t,
basic_vertex_properties<>::node_name_type basic_vertex_properties<>::*
>::type
node_name_map1(boost::get(&basic_vertex_properties<>::m_node_name, c));
but with this I again have some error (just change "type" to "const_type"
adj_list1_t c(10);
boost::property_map<adj_list1_t,
basic_vertex_properties<>::node_name_type basic_vertex_properties<>::*
>::const_type
node_name_map1(boost::get(&basic_vertex_properties<>::m_node_name, c));
1>------ Build started: Project: TestBoostGraph1, Configuration: Debug
Win32 ------
1>Compiling...
1>TestBoostGraph1.cpp
1>d:\documents and settings\dmitry\my documents\visual studio
2005\projects\testboostgraph1\testboostgraph1\testboostgraph1.cpp(79) :
error C2664:
'boost::bundle_property_map<Graph,Descriptor,Bundle,T>::bundle_property_map(const
boost::bundle_property_map<Graph,Descriptor,Bundle,T> &)' : cannot
convert parameter 1 from
'boost::bundle_property_map<Graph,Descriptor,Bundle,T>' to 'const
boost::bundle_property_map<Graph,Descriptor,Bundle,T> &'
1> with
1> [
1> Graph=const adj_list1_t,
1> Descriptor=void *,
1> Bundle=basic_vertex_properties<discret_net_t>,
1> T=const basic_vertex_properties<discret_net_t>::node_name_type
1> ]
1> and
1> [
1> Graph=adj_list1_t,
1> Descriptor=void *,
1> Bundle=basic_vertex_properties<discret_net_t>,
1> T=basic_vertex_properties<discret_net_t>::node_name_type
1> ]
1> and
1> [
1> Graph=const adj_list1_t,
1> Descriptor=void *,
1> Bundle=basic_vertex_properties<discret_net_t>,
1> T=const basic_vertex_properties<discret_net_t>::node_name_type
1> ]
1> Reason: cannot convert from
'boost::bundle_property_map<Graph,Descriptor,Bundle,T>' to 'const
boost::bundle_property_map<Graph,Descriptor,Bundle,T>'
1> with
1> [
1> Graph=adj_list1_t,
1> Descriptor=void *,
1> Bundle=basic_vertex_properties<discret_net_t>,
1> T=basic_vertex_properties<discret_net_t>::node_name_type
1> ]
1> and
1> [
1> Graph=const adj_list1_t,
1> Descriptor=void *,
1> Bundle=basic_vertex_properties<discret_net_t>,
1> T=const basic_vertex_properties<discret_net_t>::node_name_type
1> ]
1> No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called
1>TestBoostGraph1 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What is wrong here?
Any help would be greatly appreciated,
Thanks in advance,
--dima
// TestBoostGraph1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/adjacency_matrix.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/graph/copy.hpp> ///Just for read "work around"
///Two typedefs for modeling both "discrete" & "continues" nets
typedef int discret_net_t;
typedef double continues_net_t;
///
typedef enum {PLACE, TRANSITION} node_type_t;
/*!
* If you need some more properties, then you should define your property class that derived from
* basic_vertex_properties<>; - for nodes,
* basic_edge_properties<>; - for edges
* Example:
struct my_node_prop : basic_vertex_properties<discret_net_t> {
typedef double node_delay_t;
node_delay_t m_node_delay;
};
typedef CPetriNet<adj_list, boost::vecS, boost::listS, boost::bidirectionalS, my_node_prop> petri_net_t
*
* The types of all property values must be Copy Constructible, Assignable and Default Constructible!!
*/
template <class T = discret_net_t> struct basic_vertex_properties {
//typedef node_type_t my_node_type;
typedef std::string node_name_type;
typedef int node_index_t;
basic_vertex_properties(node_type_t nt = TRANSITION) : m_node_type(nt) { m_token_number = T(0);}
T m_token_number; ///Only for place, possible costruct "continues" nets
node_name_type m_node_name;
node_type_t m_node_type; ///Vertex could be "Place" or "transition"
node_index_t m_node_index;///Internal property for convenient vertices lookup
};
///Basic properties for edge
template <class T = discret_net_t> struct basic_edge_properties {
typedef int edge_index_t;
basic_edge_properties(T ew = 0) : m_weight(ew) {}
//private:
T m_weight; ///possible construct "continues" nets
edge_index_t m_edge_index; ///Internal property for convenient vertices lookup;
};
using boost::bidirectionalS;
using boost::directedS;
using boost::no_property;
struct my_ver_p : public basic_vertex_properties<discret_net_t>
{
double m_node_delay;
};
struct my_edge_p : public basic_edge_properties<discret_net_t>
{
double m_edge_delay;
};
int _tmain(int argc, _TCHAR* argv[])
{
//typedef boost::adjacency_list<boost::listS, boost::listS, directedS, my_ver_p> adj_list1_t;
typedef boost::adjacency_list<boost::listS, boost::listS, directedS, basic_vertex_properties<> > adj_list1_t;
adj_list1_t c(10);
boost::property_map<adj_list1_t, basic_vertex_properties<>::node_name_type basic_vertex_properties<>::* >::const_type
node_name_map1(boost::get(&basic_vertex_properties<>::m_node_name, c));
boost::print_graph(c, node_name_map1) ;
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