lvalue_pmap.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //=======================================================================
  2. // Copyright 2002 Indiana University.
  3. // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //=======================================================================
  9. #include <boost/graph/properties.hpp>
  10. #include <boost/graph/adjacency_list.hpp>
  11. using namespace boost;
  12. struct vertex_info_t { };
  13. struct edge_info_t { };
  14. namespace boost {
  15. BOOST_INSTALL_PROPERTY(vertex, info);
  16. BOOST_INSTALL_PROPERTY(edge, info);
  17. };
  18. typedef property<vertex_info_t, double> vertex_properties;
  19. typedef property<edge_info_t, double> edge_properties;
  20. typedef adjacency_list<vecS, vecS, bidirectionalS,
  21. vertex_properties, edge_properties> graph_t;
  22. double& foo_1(graph_t& x)
  23. {
  24. property_map<graph_t, vertex_info_t>::type pmap
  25. = get(vertex_info_t(), x);
  26. return pmap[vertex(0, x)];
  27. }
  28. const double& foo_2(graph_t const & x)
  29. {
  30. property_map<graph_t, vertex_info_t>::const_type pmap
  31. = get(vertex_info_t(), x);
  32. return pmap[vertex(0, x)];
  33. }
  34. double& bar_1(graph_t& x)
  35. {
  36. property_map<graph_t, edge_info_t>::type pmap
  37. = get(edge_info_t(), x);
  38. return pmap[edge(vertex(0, x), vertex(1, x), x).first];
  39. }
  40. const double& bar_2(graph_t const & x)
  41. {
  42. property_map<graph_t, edge_info_t>::const_type pmap
  43. = get(edge_info_t(), x);
  44. return pmap[edge(vertex(0, x), vertex(1, x), x).first];
  45. }
  46. int
  47. main()
  48. {
  49. return 0;
  50. }