algorithms.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2005-2012.
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/container for documentation.
  10. //
  11. //////////////////////////////////////////////////////////////////////////////
  12. #ifndef BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP
  13. #define BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP
  14. #if defined(_MSC_VER)
  15. # pragma once
  16. #endif
  17. #include "config_begin.hpp"
  18. #include <boost/container/detail/workaround.hpp>
  19. #include <boost/type_traits/has_trivial_copy.hpp>
  20. #include <boost/type_traits/has_trivial_assign.hpp>
  21. #include <boost/detail/no_exceptions_support.hpp>
  22. #include <boost/container/detail/type_traits.hpp>
  23. #include <boost/container/detail/mpl.hpp>
  24. #include <boost/container/detail/iterators.hpp>
  25. #include <cstring>
  26. namespace boost {
  27. namespace container {
  28. template<class It>
  29. struct is_value_init_construct_iterator
  30. {
  31. static const bool value = false;
  32. };
  33. template<class U, class D>
  34. struct is_value_init_construct_iterator<value_init_construct_iterator<U, D> >
  35. {
  36. static const bool value = true;
  37. };
  38. template<class It>
  39. struct is_emplace_iterator
  40. {
  41. static const bool value = false;
  42. };
  43. template<class U, class EF, class D>
  44. struct is_emplace_iterator<emplace_iterator<U, EF, D> >
  45. {
  46. static const bool value = true;
  47. };
  48. template<class A, class T, class InpIt>
  49. inline void construct_in_place(A &a, T* dest, InpIt source)
  50. { boost::container::allocator_traits<A>::construct(a, dest, *source); }
  51. //#endif
  52. template<class A, class T, class U, class D>
  53. inline void construct_in_place(A &a, T *dest, value_init_construct_iterator<U, D>)
  54. {
  55. boost::container::allocator_traits<A>::construct(a, dest);
  56. }
  57. template<class A, class T, class U, class D>
  58. inline void construct_in_place(A &a, T *dest, default_init_construct_iterator<U, D>)
  59. {
  60. boost::container::allocator_traits<A>::construct(a, dest, default_init);
  61. }
  62. template<class A, class T, class U, class EF, class D>
  63. inline void construct_in_place(A &a, T *dest, emplace_iterator<U, EF, D> ei)
  64. {
  65. ei.construct_in_place(a, dest);
  66. }
  67. } //namespace container {
  68. } //namespace boost {
  69. #include <boost/container/detail/config_end.hpp>
  70. #endif //#ifndef BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP