any_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_ANY_COLLECTION_HPP
  9. #define BOOST_POLY_COLLECTION_ANY_COLLECTION_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/poly_collection/any_collection_fwd.hpp>
  14. #include <boost/poly_collection/detail/any_model.hpp>
  15. #include <boost/poly_collection/detail/poly_collection.hpp>
  16. #include <utility>
  17. namespace boost{
  18. namespace poly_collection{
  19. template<typename Concept,typename Allocator>
  20. class any_collection:
  21. public common_impl::poly_collection<detail::any_model<Concept>,Allocator>
  22. {
  23. using base_type=common_impl::poly_collection<
  24. detail::any_model<Concept>,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. any_collection()=default;
  30. any_collection(const any_collection& x)=default;
  31. any_collection(any_collection&& x)=default;
  32. any_collection& operator=(const any_collection& x)=default;
  33. any_collection& operator=(any_collection&& x)=default;
  34. template<typename C,typename A>
  35. friend bool operator==(
  36. const any_collection<C,A>&,const any_collection<C,A>&);
  37. };
  38. template<typename Concept,typename Allocator>
  39. bool operator==(
  40. const any_collection<Concept,Allocator>& x,
  41. const any_collection<Concept,Allocator>& y)
  42. {
  43. return x.base()==y.base();
  44. }
  45. template<typename Concept,typename Allocator>
  46. bool operator!=(
  47. const any_collection<Concept,Allocator>& x,
  48. const any_collection<Concept,Allocator>& y)
  49. {
  50. return !(x==y);
  51. }
  52. template<typename Concept,typename Allocator>
  53. void swap(
  54. any_collection<Concept,Allocator>& x,any_collection<Concept,Allocator>& y)
  55. {
  56. x.swap(y);
  57. }
  58. } /* namespace */
  59. using poly_collection::any_collection;
  60. } /* namespace boost */
  61. #endif