lambda.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 <string>
  20. #include <boost/bimap/bimap.hpp>
  21. #include <boost/bimap/support/lambda.hpp>
  22. using namespace boost::bimaps;
  23. int main()
  24. {
  25. //[ code_bimap_and_boost_lambda
  26. typedef bimap< std::string, int > bm_type;
  27. bm_type bm;
  28. bm.insert( bm_type::value_type("one",1) );
  29. bm.insert( bm_type::value_type("two",2) );
  30. bm.right.range( 5 < _key, _key < 10 );
  31. bm.left.modify_key( bm.left.find("one"), _key = "1" );
  32. bm.left.modify_data( bm.left.begin(), _data *= 10 );
  33. //]
  34. return 0;
  35. }