interal properites with boost.graph question
I've apparently succeeded in switching from external to internal
properites in my application.
However, I've done things in an OOP way, and would like to know if
somebody can point out potential trouble.
I've a class, called Graph, that inherits from the boost::graph object.
The start of its definition is:
class Graph : public GraphT
{
public:
Graph();
// Graph Data accessor methods
typedef boost::property_map
On Aug 31, 2004, at 1:13 PM, Jeffrey Holle wrote:
// Graph Data accessor methods typedef boost::property_map
::type VertexData; typedef boost::property_map ::type EdgeData; const VertexData& getVertexData(void) const {return vertexData_;} ...
FWIW, this type of thing will get easier in 1.32.0 because we'll actually support dropping user-defined classes into adjacency_list, adjacency_matrix, etc. for vertex and edge properties; but this is the currently the best solution.
I guess my biggest concern is initializing vertexData_ once, before the graph has any data, and keeping it around though the life of the graph. Is this safe?
It's safe.
Also, I expect clients of this class to be able to use the operator[] method via getVertexData(). Will this work?
Yes, to an extent. The only issue is that const/non-const access to
properties won't be correct, because the types of property_map
Hi, newbie here. I'm trying to learn the boost lambda library in
simple steps, and am getting an error in the following snippet.
Apparently, lambda now only allows format& objects as arguments to
cout. This puzzles me because all the documentation I've seen on BLL
has examples very much like what I"m using. Has there been a design
change? Does anyone know what's going on?
Thanks in advance.
Max Wilson
#include <iostream>
#include
What errors do you get? -delfin
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Maximilian W. Sent: Tuesday, August 31, 2004 11:36 AM To: boost-users@lists.boost.org Subject: [Boost-users] Newbie learning lambda library
Hi, newbie here. I'm trying to learn the boost lambda library in simple steps, and am getting an error in the following snippet. Apparently, lambda now only allows format& objects as arguments to cout. This puzzles me because all the documentation I've seen on BLL has examples very much like what I"m using. Has there been a design change? Does anyone know what's going on?
Thanks in advance.
Max Wilson
#include <iostream> #include
#include #include <vector> #include <algorithm> using namespace std; using namespace boost::lambda;
int main(int argc, char *argv[]) { vector<int> vec; vec.push_back(1); vec.push_back(2); for_each(vec.begin(), vec.end(), cout << _1 << endl); return 0; }
#include <iostream> #include
#include "/users/user2/ugrad/m/mdw45/boost_1_31_0/boost/lambda/lambda.hpp" #include #include <vector> #include #include <algorithm> using namespace std; using namespace boost::lambda;
int main(int argc, char *argv[]) { vector<int> vec; vec.push_back(1); vec.push_back(2); for_each(vec.begin(), vec.end(), cout << _1 << endl); return 0; }
--
Sometimes I think decisions through, weigh the consequences, decide it is not a good idea, but blind myself and make it anyway. I do not think this is a good thing to do, but it might be. Humans are endowed with both reason and emotion for a reason. -Tara Greenwood _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Tue, 31 Aug 2004 13:55:23 -0700, Delfin Rojas
What errors do you get?
-delfin
Whoops! I forgot to paste in the error text. /users/ugrad/m/mdw45/465/project1/src/project1.cpp:26: error: no match for 'operator<<' in 'boost::lambda::operator<<(A&, const boost::lambda::lambda_functor<Arg>&) [with A = std::ostream, Arg = boost::lambda::placeholder<1>]((+boost::lambda::<unnamed>::_1)) << std::endl ' */users/user2/ugrad/m/mdw45/lib/format.h:126: error: candidates are: std::ostream& operator<<(std::ostream&, const format&) It says there's no operator for the expression <<(cout, _1). To my understanding, that should return a one-argument lambda functor which outputs its argument on cout. Was this capability removed or am I missing some header files? (I'll tell you if I solve it before you do.) Max Wilson -- Sometimes I think decisions through, weigh the consequences, decide it is not a good idea, but blind myself and make it anyway. I do not think this is a good thing to do, but it might be. Humans are endowed with both reason and emotion for a reason. -Tara Greenwood
Maximilian W. wrote:
On Tue, 31 Aug 2004 13:55:23 -0700, Delfin Rojas
wrote: What errors do you get?
-delfin
Whoops! I forgot to paste in the error text.
/users/ugrad/m/mdw45/465/project1/src/project1.cpp:26: error: no match for 'operator<<' in 'boost::lambda::operator<<(A&, const boost::lambda::lambda_functor<Arg>&) [with A = std::ostream, Arg = boost::lambda::placeholder<1>]((+boost::lambda::<unnamed>::_1)) << std::endl ' */users/user2/ugrad/m/mdw45/lib/format.h:126: error: candidates are: std::ostream& operator<<(std::ostream&, const format&)
It says there's no operator for the expression <<(cout, _1).
No, it says there's no operator<< for (cout << _1) and std::endl. std::endl is an overloaded function and doesn't work with lambda. cout << _1 << '\n' should work.
participants (5)
-
Delfin Rojas
-
Doug Gregor
-
Jeffrey Holle
-
Maximilian W.
-
Peter Dimov