null_property_map.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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>
  17. struct null_property_map
  18. {
  19. typedef Key key_type;
  20. typedef Value value_type;
  21. typedef void reference;
  22. typedef boost::writable_property_map_tag category;
  23. };
  24. // The null_property_map<K,V> only has a put() function.
  25. template <typename K, typename V>
  26. void put(null_property_map<K,V>& /*pm*/, const K& /*key*/, const V& /*value*/)
  27. { }
  28. // A helper function for intantiating null property maps.
  29. template <typename Key, typename Value>
  30. inline null_property_map<Key, Value> make_null_property()
  31. { return null_property_map<Key, Value>(); }
  32. }
  33. #endif