function_collection.hpp 2.1 KB

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