property_map.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Boost.Bimap
  2. //
  3. // Copyright (c) 2006-2007 Matias Capeletto
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. // VC++ 8.0 warns on usage of certain Standard Library and API functions that
  9. // can be cause buffer overruns or other possible security issues if misused.
  10. // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
  11. // But the wording of the warning is misleading and unsettling, there are no
  12. // portable alternative functions, and VC++ 8.0's own libraries use the
  13. // functions in question. So turn off the warnings.
  14. #define _CRT_SECURE_NO_DEPRECATE
  15. #define _SCL_SECURE_NO_DEPRECATE
  16. // Boost.Bimap Example
  17. //-----------------------------------------------------------------------------
  18. #include <boost/config.hpp>
  19. #include <iostream>
  20. #include <string>
  21. #include <boost/bimap/bimap.hpp>
  22. #include <boost/bimap/multiset_of.hpp>
  23. #include <boost/bimap/property_map/set_support.hpp>
  24. using namespace boost::bimaps;
  25. //[ code_bimap_and_boost_property_map
  26. template <typename AddressMap>
  27. void foo(AddressMap & address_map)
  28. {
  29. typedef typename boost::property_traits<AddressMap>::value_type value_type;
  30. typedef typename boost::property_traits<AddressMap>::key_type key_type;
  31. value_type address;
  32. key_type fred = "Fred";
  33. std::cout << boost::get(address_map, fred);
  34. }
  35. int main()
  36. {
  37. typedef bimap<std::string, multiset_of<std::string> > Name2Address;
  38. typedef Name2Address::value_type location;
  39. Name2Address name2address;
  40. name2address.insert( location("Fred", "710 West 13th Street") );
  41. name2address.insert( location( "Joe", "710 West 13th Street") );
  42. foo( name2address.left );
  43. return 0;
  44. }
  45. //]