null_property_map.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // (C) Copyright Andrew Sutton 2007
  2. //
  3. // Use, modification and distribution are subject to the
  4. // Boost Software License, Version 1.0 (See accompanying file
  5. // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_GRAPH_NULL_PROPERTY_HPP
  7. #define BOOST_GRAPH_NULL_PROPERTY_HPP
  8. #include <boost/property_map/property_map.hpp>
  9. // TODO: This should really be part of the property maps library rather than
  10. // the Boost.Graph library.
  11. namespace boost
  12. {
  13. // A null property is somewhat like the inverse of the constant
  14. // property map except that instead of returning a single value,
  15. // this eats any writes and cannot be read from.
  16. template < typename Key, typename Value > struct null_property_map
  17. {
  18. typedef Key key_type;
  19. typedef Value value_type;
  20. typedef void reference;
  21. typedef boost::writable_property_map_tag category;
  22. };
  23. // The null_property_map<K,V> only has a put() function.
  24. template < typename K, typename V >
  25. void put(
  26. null_property_map< K, V >& /*pm*/, const K& /*key*/, const V& /*value*/)
  27. {
  28. }
  29. // A helper function for intantiating null property maps.
  30. template < typename Key, typename Value >
  31. inline null_property_map< Key, Value > make_null_property()
  32. {
  33. return null_property_map< Key, Value >();
  34. }
  35. }
  36. #endif