Boost logo

Boost Users :

From: TC MA (maottawa3_at_[hidden])
Date: 2004-11-23 22:56:48


I am trying to use the Boost Graph library bundled
properties which is introduced in 1.32.0.
I modify the sample program
libs/graph/example/interior_property_map.cpp which
then fail to compile.

using namespace std;
using namespace boost;

using std::string;

// create a tag for our new property

enum vertex_first_name_t { vertex_first_name };
namespace boost {
  BOOST_INSTALL_PROPERTY(vertex, first_name);
}

struct vertexStruct {
  string name;
};

template <class EdgeIter, class Graph>
void who_owes_who(EdgeIter first, EdgeIter last, const
Graph& G)
{
  // Access the propety acessor type for this graph
  typedef typename property_map<Graph,
vertexStruct::name>::const_type NamePA;

  NamePA name = get(vertex_first_name, G);

  typedef typename
boost::property_traits<NamePA>::value_type NameType;

  NameType src_name, targ_name;

  while (first != last) {
    src_name = boost::get(name, source(*first,G));
    targ_name = boost::get(name, target(*first,G));
    cout << src_name << " owes "
         << targ_name << " some money" << endl;
    ++first;
  }
}

int
main()
{
  {
    // Create the graph, and specify that we will use
std::string to
    // store the first name's.
    typedef adjacency_list<vecS, vecS, directedS,
      vertexStruct > MyGraphType;
    
    typedef pair<int,int> Pair;
    Pair edge_array[11] = { Pair(0,1), Pair(0,2),
Pair(0,3), Pair(0,4),
                            Pair(2,0), Pair(3,0),
Pair(2,4), Pair(3,1),
                            Pair(3,4), Pair(4,0),
Pair(4,1) };
    
    MyGraphType G(5);
    for (int i=0; i<11; ++i)
      add_edge(edge_array[i].first,
edge_array[i].second, G);
    MyGraphType::vertex_descriptor v =
*vertices(G).first;
    G[v].name = "TingChong";
    ++v;
    G[v].name = "Carmen";
  
    who_owes_who(edges(G).first, edges(G).second, G);
  }

  cout << endl;

  return 0;
}

// compile output is:
$ bjam
...found 372 targets...
...updating 4 targets...
gcc-C++-action
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.test/gcc/debug/inlining-on/interior_property_map.o
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:
In function `void who_owes_who(EdgeIter, EdgeIter,
const Graph&)':
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:73:
error: invalid use of non-static data member
`vertexStruct::name'
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:80:
error: from this location
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:80:
error: `vertexStruct::name' cannot appear in a
constant-expression
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:80:
error: template argument 2 is invalid
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:80:
error: `const_type' does not name a type
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:82:
error: `NamePA' undeclared (first use this function)
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:82:
error: (Each undeclared identifier is reported only
once for each function it appears in.)
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:82:
error: expected `;' before "name"
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:84:
error: template argument 1 is invalid
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:84:
error: `value_type' does not name a type
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:86:
error: `NameType' undeclared (first use this function)
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:86:
error: expected `;' before "src_name"
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:89:
error: `src_name' undeclared (first use this function)
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:89:
error: `name' undeclared (first use this function)
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp:90:
error: `targ_name' undeclared (first use this
function)

    set -e
    "g++" -c -Wall -ftemplate-depth-255 -g -O0
-Wno-inline
-I"../../../bin/boost/libs/graph/example" -I
"/home/tcma/cpp/boost_1_32_0" -o
"/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.test/gcc/debug/inlining-on/interior_property_map.o"

"/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.cpp"
    "/usr/bin/objcopy" --set-section-flags
.debug_str=contents,debug
"/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.test/gcc/debug/inlining-on/interior_property_map.o"

...failed gcc-C++-action
/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.test/gcc/debug/inlining-on/interior_property_map.o...
...skipped
</home/tcma/cpp/boosttcma/libs/graph/interior_property_map.test/gcc/debug/inlining-on>/home/tcma/cpp/boosttcma/libs/graph/interior_property_map
for lack of
</home/tcma/cpp/boosttcma/libs/graph/interior_property_map.test/gcc/debug/inlining-on>interior_property_map.o...
...skipped
</home/tcma/cpp/boosttcma/libs/graph/interior_property_map.test/gcc/debug/inlining-on>/home/tcma/cpp/boosttcma/libs/graph/interior_property_map.run
for lack of
</home/tcma/cpp/boosttcma/libs/graph/interior_property_map.test/gcc/debug/inlining-on>/home/tcma/cpp/boosttcma/libs/graph/interior_property_map...
...failed updating 1 target...
...skipped 3 targets...

=====
TingChong Ma

______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca


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