• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
9 #ifndef BOOST_POLY_COLLECTION_ANY_COLLECTION_HPP
10 #define BOOST_POLY_COLLECTION_ANY_COLLECTION_HPP
11 
12 #if defined(_MSC_VER)
13 #pragma once
14 #endif
15 
16 #include <boost/poly_collection/any_collection_fwd.hpp>
17 #include <boost/poly_collection/detail/any_model.hpp>
18 #include <boost/poly_collection/detail/poly_collection.hpp>
19 #include <utility>
20 
21 namespace boost{
22 
23 namespace poly_collection{
24 
25 template<typename Concept,typename Allocator>
26 class any_collection:
27  public common_impl::poly_collection<detail::any_model<Concept>,Allocator>
28 {
29   using base_type=common_impl::poly_collection<
30     detail::any_model<Concept>,Allocator>;
31 
base()32   base_type&       base()noexcept{return *this;}
base() const33   const base_type& base()const noexcept{return *this;}
34 
35 public:
36   using base_type::base_type;
37 
38   any_collection()=default;
39   any_collection(const any_collection& x)=default;
40   any_collection(any_collection&& x)=default;
41   any_collection& operator=(const any_collection& x)=default;
42   any_collection& operator=(any_collection&& x)=default;
43 
44   template<typename C,typename A>
45   friend bool operator==(
46     const any_collection<C,A>&,const any_collection<C,A>&);
47 };
48 
49 template<typename Concept,typename Allocator>
operator ==(const any_collection<Concept,Allocator> & x,const any_collection<Concept,Allocator> & y)50 bool operator==(
51   const any_collection<Concept,Allocator>& x,
52   const any_collection<Concept,Allocator>& y)
53 {
54   return x.base()==y.base();
55 }
56 
57 template<typename Concept,typename Allocator>
operator !=(const any_collection<Concept,Allocator> & x,const any_collection<Concept,Allocator> & y)58 bool operator!=(
59   const any_collection<Concept,Allocator>& x,
60   const any_collection<Concept,Allocator>& y)
61 {
62  return !(x==y);
63 }
64 
65 template<typename Concept,typename Allocator>
swap(any_collection<Concept,Allocator> & x,any_collection<Concept,Allocator> & y)66 void swap(
67   any_collection<Concept,Allocator>& x,any_collection<Concept,Allocator>& y)
68 {
69   x.swap(y);
70 }
71 
72 } /* namespace  */
73 
74 using poly_collection::any_collection;
75 
76 } /* namespace boost */
77 
78 #endif
79