compose_property_map_example.cpp 889 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2013 Eurodecision
  2. // Authors: Guillaume Pinot
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See
  5. // accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <boost/property_map/compose_property_map.hpp>
  8. #include <iostream>
  9. int main()
  10. {
  11. const int idx[] = {2, 0, 4, 1, 3};
  12. double v[] = {1., 3., 0., 4., 2.};
  13. boost::compose_property_map<double*, const int*> cpm(v, idx);
  14. for (int i = 0; i < 5; ++i)
  15. std::cout << get(cpm, i) << " ";
  16. std::cout << std::endl;
  17. for (int i = 0; i < 5; ++i)
  18. ++cpm[i];
  19. for (int i = 0; i < 5; ++i)
  20. std::cout << get(cpm, i) << " ";
  21. std::cout << std::endl;
  22. for (int i = 0; i < 5; ++i)
  23. put(cpm, i, 42.);
  24. for (int i = 0; i < 5; ++i)
  25. std::cout << get(cpm, i) << " ";
  26. std::cout << std::endl;
  27. return 0;
  28. }