container_or_allocator_rebind.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2017-2017. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_CONTAINER_DETAIL_CONTAINER_OR_ALLOCATOR_REBIND_HPP
  11. #define BOOST_CONTAINER_DETAIL_CONTAINER_OR_ALLOCATOR_REBIND_HPP
  12. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #if defined(BOOST_HAS_PRAGMA_ONCE)
  16. # pragma once
  17. #endif
  18. #include <boost/container/allocator_traits.hpp>
  19. #include <boost/container/detail/container_rebind.hpp>
  20. #include <boost/container/detail/is_container.hpp>
  21. namespace boost {
  22. namespace container {
  23. namespace dtl {
  24. template<class AllocatorOrContainer, class ToType, bool = is_container<AllocatorOrContainer>::value>
  25. struct container_or_allocator_rebind_impl
  26. : container_rebind<AllocatorOrContainer, ToType>
  27. {};
  28. template<class AllocatorOrContainer, class ToType>
  29. struct container_or_allocator_rebind_impl<AllocatorOrContainer, ToType, false>
  30. : allocator_traits<AllocatorOrContainer>::template portable_rebind_alloc<ToType>
  31. {};
  32. template<class ToType>
  33. struct container_or_allocator_rebind_impl<void, ToType, false>
  34. : real_allocator<ToType, void>
  35. {};
  36. template<class AllocatorOrContainer, class ToType>
  37. struct container_or_allocator_rebind
  38. : container_or_allocator_rebind_impl<AllocatorOrContainer, ToType>
  39. {};
  40. } //namespace dtl {
  41. } //namespace container {
  42. } //namespace boost {
  43. #endif //#ifndef BOOST_CONTAINER_DETAIL_CONTAINER_OR_ALLOCATOR_REBIND_HPP