key_extractor.hpp 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. /// \file container_adaptor/detail/key_extractor.hpp
  9. /// \brief Key extractor for a pair<Key,Data>.
  10. #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_KEY_EXTRACTOR_HPP
  11. #define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_KEY_EXTRACTOR_HPP
  12. #if defined(_MSC_VER)
  13. #pragma once
  14. #endif
  15. #include <boost/config.hpp>
  16. namespace boost {
  17. namespace bimaps {
  18. namespace container_adaptor {
  19. namespace detail {
  20. /// \brief Key Extractor
  21. template < class T >
  22. struct key_from_pair_extractor
  23. {
  24. typedef T argument_type;
  25. typedef BOOST_DEDUCED_TYPENAME T::first_type result_type;
  26. result_type operator()( const T & p ) { return p.first; }
  27. };
  28. } // namespace detail
  29. } // namespace container_adaptor
  30. } // namespace bimaps
  31. } // namespace boost
  32. #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_KEY_EXTRACTOR_HPP