base_collection.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Copyright 2016-2017 Joaquin M Lopez Munoz.
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * See http://www.boost.org/libs/poly_collection for library home page.
  7. */
  8. #ifndef BOOST_POLY_COLLECTION_BASE_COLLECTION_HPP
  9. #define BOOST_POLY_COLLECTION_BASE_COLLECTION_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/poly_collection/base_collection_fwd.hpp>
  14. #include <boost/poly_collection/detail/base_model.hpp>
  15. #include <boost/poly_collection/detail/poly_collection.hpp>
  16. #include <utility>
  17. namespace boost{
  18. namespace poly_collection{
  19. template<typename Base,typename Allocator>
  20. class base_collection:
  21. public common_impl::poly_collection<detail::base_model<Base>,Allocator>
  22. {
  23. using base_type=common_impl::poly_collection<
  24. detail::base_model<Base>,Allocator>;
  25. base_type& base()noexcept{return *this;}
  26. const base_type& base()const noexcept{return *this;}
  27. public:
  28. using base_type::base_type;
  29. base_collection()=default;
  30. base_collection(const base_collection& x)=default;
  31. base_collection(base_collection&& x)=default;
  32. base_collection& operator=(const base_collection& x)=default;
  33. base_collection& operator=(base_collection&& x)=default;
  34. template<typename B,typename A>
  35. friend bool operator==(
  36. const base_collection<B,A>&,const base_collection<B,A>&);
  37. };
  38. template<typename Base,typename Allocator>
  39. bool operator==(
  40. const base_collection<Base,Allocator>& x,
  41. const base_collection<Base,Allocator>& y)
  42. {
  43. return x.base()==y.base();
  44. }
  45. template<typename Base,typename Allocator>
  46. bool operator!=(
  47. const base_collection<Base,Allocator>& x,
  48. const base_collection<Base,Allocator>& y)
  49. {
  50. return !(x==y);
  51. }
  52. template<typename Base,typename Allocator>
  53. void swap(
  54. base_collection<Base,Allocator>& x,base_collection<Base,Allocator>& y)
  55. {
  56. x.swap(y);
  57. }
  58. } /* namespace */
  59. using poly_collection::base_collection;
  60. } /* namespace boost */
  61. #endif