9
3

pairs.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Boost.Geometry Index
  2. //
  3. // Pairs intended to be used internally in nodes.
  4. //
  5. // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
  6. //
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_PAIRS_HPP
  11. #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_PAIRS_HPP
  12. #include <boost/move/move.hpp>
  13. namespace boost { namespace geometry { namespace index {
  14. namespace detail { namespace rtree {
  15. template <typename First, typename Pointer>
  16. class ptr_pair
  17. {
  18. public:
  19. typedef First first_type;
  20. typedef Pointer second_type;
  21. ptr_pair(First const& f, Pointer s) : first(f), second(s) {}
  22. //ptr_pair(ptr_pair const& p) : first(p.first), second(p.second) {}
  23. //ptr_pair & operator=(ptr_pair const& p) { first = p.first; second = p.second; return *this; }
  24. first_type first;
  25. second_type second;
  26. };
  27. template <typename First, typename Pointer> inline
  28. ptr_pair<First, Pointer>
  29. make_ptr_pair(First const& f, Pointer s)
  30. {
  31. return ptr_pair<First, Pointer>(f, s);
  32. }
  33. // TODO: It this will be used, rename it to unique_ptr_pair and possibly use unique_ptr.
  34. template <typename First, typename Pointer>
  35. class exclusive_ptr_pair
  36. {
  37. BOOST_MOVABLE_BUT_NOT_COPYABLE(exclusive_ptr_pair)
  38. public:
  39. typedef First first_type;
  40. typedef Pointer second_type;
  41. exclusive_ptr_pair(First const& f, Pointer s) : first(f), second(s) {}
  42. // INFO - members aren't really moved!
  43. exclusive_ptr_pair(BOOST_RV_REF(exclusive_ptr_pair) p) : first(p.first), second(p.second) { p.second = 0; }
  44. exclusive_ptr_pair & operator=(BOOST_RV_REF(exclusive_ptr_pair) p) { first = p.first; second = p.second; p.second = 0; return *this; }
  45. first_type first;
  46. second_type second;
  47. };
  48. template <typename First, typename Pointer> inline
  49. exclusive_ptr_pair<First, Pointer>
  50. make_exclusive_ptr_pair(First const& f, Pointer s)
  51. {
  52. return exclusive_ptr_pair<First, Pointer>(f, s);
  53. }
  54. }} // namespace detail::rtree
  55. }}} // namespace boost::geometry::index
  56. #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_PAIRS_HPP