container_gen.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //=======================================================================
  2. // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
  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/adjacency_list.hpp>
  10. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_STD_ALLOCATOR)
  11. template <class Allocator>
  12. struct list_with_allocatorS { };
  13. namespace boost {
  14. template <class Alloc, class ValueType>
  15. struct container_gen<list_with_allocatorS<Alloc>, ValueType> {
  16. typedef typename Alloc::template rebind<ValueType>::other Allocator;
  17. typedef std::list<ValueType, Allocator> type;
  18. };
  19. template <class Alloc>
  20. struct parallel_edge_traits< list_with_allocatorS<Alloc> > {
  21. typedef allow_parallel_edge_tag type;
  22. };
  23. }
  24. // now you can define a graph using std::list and a specific allocator
  25. typedef boost::adjacency_list< list_with_allocatorS< std::allocator<int> >,
  26. boost::vecS, boost::directedS> MyGraph;
  27. int main(int, char*[])
  28. {
  29. MyGraph g(5);
  30. return 0;
  31. }
  32. #else
  33. int main(int, char*[])
  34. {
  35. return 0;
  36. }
  37. #endif