BVB Source Codes

mars Show allocator_traits.hpp Source code

Return Download mars: download allocator_traits.hpp Source code - Download mars Source code - Type:.hpp
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Pablo Halpern 2009. 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. //////////////////////////////////////////////////////////////////////////////
  8. //
  9. // (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost
  10. // Software License, Version 1.0. (See accompanying file
  11. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  12. //
  13. // See http://www.boost.org/libs/container for documentation.
  14. //
  15. //////////////////////////////////////////////////////////////////////////////
  16. #ifndef BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP
  17. #define BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP
  18.  
  19. #ifndef BOOST_CONFIG_HPP
  20. #  include <boost/config.hpp>
  21. #endif
  22.  
  23. #if defined(BOOST_HAS_PRAGMA_ONCE)
  24. #  pragma once
  25. #endif
  26.  
  27. #include <boost/container/detail/config_begin.hpp>
  28. #include <boost/container/detail/workaround.hpp>
  29.  
  30. // container
  31. #include <boost/container/container_fwd.hpp>
  32. #include <boost/container/detail/mpl.hpp>
  33. #include <boost/container/detail/type_traits.hpp>  //is_empty
  34. #include <boost/container/detail/placement_new.hpp>
  35. #ifndef BOOST_CONTAINER_DETAIL_STD_FWD_HPP
  36. #include <boost/container/detail/std_fwd.hpp>
  37. #endif
  38. // intrusive
  39. #include <boost/intrusive/pointer_traits.hpp>
  40. #include <boost/intrusive/detail/mpl.hpp>
  41. // move
  42. #include <boost/move/utility_core.hpp>
  43. // move/detail
  44. #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  45. #include <boost/move/detail/fwd_macros.hpp>
  46. #endif
  47. // other boost
  48. #include <boost/static_assert.hpp>
  49.  
  50. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  51.  
  52. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME allocate
  53. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost { namespace container { namespace container_detail {
  54. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
  55. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 2
  56. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 2
  57. #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
  58.  
  59. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME destroy
  60. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost { namespace container { namespace container_detail {
  61. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
  62. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 1
  63. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 1
  64. #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
  65.  
  66. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME construct
  67. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost { namespace container { namespace container_detail {
  68. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
  69. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 1
  70. #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 9
  71. #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
  72.  
  73. #endif   //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  74.  
  75. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  76. namespace container {
  77.  
  78. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  79.  
  80. namespace allocator_traits_detail {
  81.  
  82. BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_max_size, max_size)
  83. BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_select_on_container_copy_construction, select_on_container_copy_construction)
  84.  
  85. }  //namespace allocator_traits_detail {
  86.  
  87. namespace container_detail {
  88.  
  89. //workaround needed for C++03 compilers with no construct()
  90. //supporting rvalue references
  91. template<class Allocator>
  92. struct is_std_allocator
  93. {  static const bool value = false; };
  94.  
  95. template<class T>
  96. struct is_std_allocator< std::allocator<T> >
  97. {  static const bool value = true; };
  98.  
  99. template<class Allocator>
  100. struct is_not_std_allocator
  101. {  static const bool value = !is_std_allocator<Allocator>::value; };
  102.  
  103. BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer)
  104. BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(const_pointer)
  105. BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference)
  106. BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference)
  107. BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(void_pointer)
  108. BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(const_void_pointer)
  109. BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type)
  110. BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment)
  111. BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment)
  112. BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap)
  113. BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(is_always_equal)
  114. BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type)
  115. BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(is_partially_propagable)
  116.  
  117. }  //namespace container_detail {
  118.  
  119. #endif   //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  120.  
  121. //! The class template allocator_traits supplies a uniform interface to all allocator types.
  122. //! This class is a C++03-compatible implementation of std::allocator_traits
  123. template <typename Allocator>
  124. struct allocator_traits
  125. {
  126.    //allocator_type
  127.    typedef Allocator allocator_type;
  128.    //value_type
  129.    typedef typename allocator_type::value_type value_type;
  130.  
  131.    #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  132.       //! Allocator::pointer if such a type exists; otherwise, value_type*
  133.       //!
  134.       typedef unspecified pointer;
  135.       //! Allocator::const_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<const
  136.       //!
  137.       typedef see_documentation const_pointer;
  138.       //! Non-standard extension
  139.       //! Allocator::reference if such a type exists; otherwise, value_type&
  140.       typedef see_documentation reference;
  141.       //! Non-standard extension
  142.       //! Allocator::const_reference if such a type exists ; otherwise, const value_type&
  143.       typedef see_documentation const_reference;
  144.       //! Allocator::void_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<void>.
  145.       //!
  146.       typedef see_documentation void_pointer;
  147.       //! Allocator::const_void_pointer if such a type exists ; otherwis e, pointer_traits<pointer>::rebind<const
  148.       //!
  149.       typedef see_documentation const_void_pointer;
  150.       //! Allocator::difference_type if such a type exists ; otherwise, pointer_traits<pointer>::difference_type.
  151.       //!
  152.       typedef see_documentation difference_type;
  153.       //! Allocator::size_type if such a type exists ; otherwise, make_unsigned<difference_type>::type
  154.       //!
  155.       typedef see_documentation size_type;
  156.       //! Allocator::propagate_on_container_copy_assignment if such a type exists, otherwise a type
  157.       //! with an internal constant static boolean member <code>value</code> == false.
  158.       typedef see_documentation propagate_on_container_copy_assignment;
  159.       //! Allocator::propagate_on_container_move_assignment if such a type exists, otherwise a type
  160.       //! with an internal constant static boolean member <code>value</code> == false.
  161.       typedef see_documentation propagate_on_container_move_assignment;
  162.       //! Allocator::propagate_on_container_swap if such a type exists, otherwise a type
  163.       //! with an internal constant static boolean member <code>value</code> == false.
  164.       typedef see_documentation propagate_on_container_swap;
  165.       //! Allocator::is_always_equal if such a type exists, otherwise a type
  166.       //! with an internal constant static boolean member <code>value</code> == is_empty<Allocator>::value
  167.       typedef see_documentation is_always_equal;
  168.       //! Allocator::is_partially_propagable if such a type exists, otherwise a type
  169.       //! with an internal constant static boolean member <code>value</code> == false
  170.       //! <b>Note</b>: Non-standard extension used to implement `small_vector_allocator`.
  171.       typedef see_documentation is_partially_propagable;
  172.       //! Defines an allocator: Allocator::rebind<T>::other if such a type exists; otherwise, Allocator<T, Args>
  173.       //! if Allocator is a class template instantiation of the form Allocator<U, Args>, where Args is zero or
  174.       //! more type arguments ; otherwise, the instantiation of rebind_alloc is ill-formed.
  175.       //!
  176.       //! In C++03 compilers <code>rebind_alloc</code> is a struct derived from an allocator
  177.       //! deduced by previously detailed rules.
  178.       template <class T> using rebind_alloc = see_documentation;
  179.  
  180.       //! In C++03 compilers <code>rebind_traits</code> is a struct derived from
  181.       //! <code>allocator_traits<OtherAlloc></code>, where <code>OtherAlloc</code> is
  182.       //! the allocator deduced by rules explained in <code>rebind_alloc</code>.
  183.       template <class T> using rebind_traits = allocator_traits<rebind_alloc<T> >;
  184.  
  185.       //! Non-standard extension: Portable allocator rebind for C++03 and C++11 compilers.
  186.       //! <code>type</code> is an allocator related to Allocator deduced deduced by rules explained in <code>rebind_alloc</code>.
  187.       template <class T>
  188.       struct portable_rebind_alloc
  189.       {  typedef see_documentation type;  };
  190.    #else
  191.       //pointer
  192.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(mars_boost::container::container_detail::, Allocator,
  193.          pointer, value_type*)
  194.             pointer;
  195.       //const_pointer
  196.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(mars_boost::container::container_detail::, Allocator,
  197.          const_pointer, typename mars_boost::intrusive::pointer_traits<pointer>::template
  198.             rebind_pointer<const value_type>)
  199.                const_pointer;
  200.       //reference
  201.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(mars_boost::container::container_detail::, Allocator,
  202.          reference, typename container_detail::unvoid_ref<value_type>::type)
  203.             reference;
  204.       //const_reference
  205.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(mars_boost::container::container_detail::, Allocator,
  206.          const_reference, typename container_detail::unvoid_ref<const value_type>::type)
  207.                const_reference;
  208.       //void_pointer
  209.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(mars_boost::container::container_detail::, Allocator,
  210.          void_pointer, typename mars_boost::intrusive::pointer_traits<pointer>::template
  211.             rebind_pointer<void>)
  212.                void_pointer;
  213.       //const_void_pointer
  214.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(mars_boost::container::container_detail::, Allocator,
  215.          const_void_pointer, typename mars_boost::intrusive::pointer_traits<pointer>::template
  216.             rebind_pointer<const void>)
  217.                const_void_pointer;
  218.       //difference_type
  219.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(mars_boost::container::container_detail::, Allocator,
  220.          difference_type, std::ptrdiff_t)
  221.             difference_type;
  222.       //size_type
  223.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(mars_boost::container::container_detail::, Allocator,
  224.          size_type, std::size_t)
  225.             size_type;
  226.       //propagate_on_container_copy_assignment
  227.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(mars_boost::container::container_detail::, Allocator,
  228.          propagate_on_container_copy_assignment, container_detail::false_type)
  229.             propagate_on_container_copy_assignment;
  230.       //propagate_on_container_move_assignment
  231.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(mars_boost::container::container_detail::, Allocator,
  232.          propagate_on_container_move_assignment, container_detail::false_type)
  233.             propagate_on_container_move_assignment;
  234.       //propagate_on_container_swap
  235.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(mars_boost::container::container_detail::, Allocator,
  236.          propagate_on_container_swap, container_detail::false_type)
  237.             propagate_on_container_swap;
  238.       //is_always_equal
  239.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(mars_boost::container::container_detail::, Allocator,
  240.          is_always_equal, container_detail::is_empty<Allocator>)
  241.             is_always_equal;
  242.       //is_partially_propagable
  243.       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(mars_boost::container::container_detail::, Allocator,
  244.          is_partially_propagable, container_detail::false_type)
  245.             is_partially_propagable;
  246.  
  247.       //rebind_alloc & rebind_traits
  248.       #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  249.          //C++11
  250.          template <typename T> using rebind_alloc  = typename mars_boost::intrusive::pointer_rebind<Allocator, T>::type;
  251.          template <typename T> using rebind_traits = allocator_traits< rebind_alloc<T> >;
  252.       #else    // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  253.          //Some workaround for C++03 or C++11 compilers with no template aliases
  254.          template <typename T>
  255.          struct rebind_alloc : mars_boost::intrusive::pointer_rebind<Allocator,T>::type
  256.          {
  257.             typedef typename mars_boost::intrusive::pointer_rebind<Allocator,T>::type Base;
  258.             #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  259.                template <typename... Args>
  260.                rebind_alloc(BOOST_FWD_REF(Args)... args) : Base(mars_boost::forward<Args>(args)...) {}
  261.             #else    // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  262.                #define BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC(N) \
  263.                BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N\
  264.                explicit rebind_alloc(BOOST_MOVE_UREF##N) : Base(BOOST_MOVE_FWD##N){}\
  265.                //
  266.                BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC)
  267.                #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC
  268.             #endif   // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  269.          };
  270.  
  271.          template <typename T>
  272.          struct rebind_traits
  273.             : allocator_traits<typename mars_boost::intrusive::pointer_rebind<Allocator, T>::type>
  274.          {};
  275.       #endif   // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
  276.  
  277.       //portable_rebind_alloc
  278.       template <class T>
  279.       struct portable_rebind_alloc
  280.       {  typedef typename mars_boost::intrusive::pointer_rebind<Allocator, T>::type type;  };
  281.    #endif   //BOOST_CONTAINER_DOXYGEN_INVOKED
  282.  
  283.    //! <b>Returns</b>: <code>a.allocate(n)</code>
  284.    //!
  285.    static pointer allocate(Allocator &a, size_type n)
  286.    {  return a.allocate(n);  }
  287.  
  288.    //! <b>Returns</b>: <code>a.deallocate(p, n)</code>
  289.    //!
  290.    //! <b>Throws</b>: Nothing
  291.    static void deallocate(Allocator &a, pointer p, size_type n)
  292.    {  a.deallocate(p, n);  }
  293.  
  294.    //! <b>Effects</b>: calls <code>a.allocate(n, p)</code> if that call is well-formed;
  295.    //! otherwise, invokes <code>a.allocate(n)</code>
  296.    static pointer allocate(Allocator &a, size_type n, const_void_pointer p)
  297.    {
  298.       const bool value = mars_boost::container::container_detail::
  299.          has_member_function_callable_with_allocate
  300.             <Allocator, const size_type, const const_void_pointer>::value;
  301.       container_detail::bool_<value> flag;
  302.       return allocator_traits::priv_allocate(flag, a, n, p);
  303.    }
  304.  
  305.    //! <b>Effects</b>: calls <code>a.destroy(p)</code> if that call is well-formed;
  306.    //! otherwise, invokes <code>p->~T()</code>.
  307.    template<class T>
  308.    static void destroy(Allocator &a, T*p) BOOST_NOEXCEPT_OR_NOTHROW
  309.    {
  310.       typedef T* destroy_pointer;
  311.       const bool value = mars_boost::container::container_detail::
  312.          has_member_function_callable_with_destroy
  313.             <Allocator, const destroy_pointer>::value;
  314.       container_detail::bool_<value> flag;
  315.       allocator_traits::priv_destroy(flag, a, p);
  316.    }
  317.  
  318.    //! <b>Returns</b>: <code>a.max_size()</code> if that expression is well-formed; otherwise,
  319.    //! <code>numeric_limits<size_type>::max()</code>.
  320.    static size_type max_size(const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW
  321.    {
  322.       const bool value = allocator_traits_detail::has_max_size<Allocator, size_type (Allocator::*)() const>::value;
  323.       container_detail::bool_<value> flag;
  324.       return allocator_traits::priv_max_size(flag, a);
  325.    }
  326.  
  327.    //! <b>Returns</b>: <code>a.select_on_container_copy_construction()</code> if that expression is well-formed;
  328.    //! otherwise, a.
  329.    static BOOST_CONTAINER_DOC1ST(Allocator,
  330.       typename container_detail::if_c
  331.          < allocator_traits_detail::has_select_on_container_copy_construction<Allocator BOOST_MOVE_I Allocator (Allocator::*)() const>::value
  332.          BOOST_MOVE_I Allocator BOOST_MOVE_I const Allocator & >::type)
  333.    select_on_container_copy_construction(const Allocator &a)
  334.    {
  335.       const bool value = allocator_traits_detail::has_select_on_container_copy_construction
  336.          <Allocator, Allocator (Allocator::*)() const>::value;
  337.       container_detail::bool_<value> flag;
  338.       return allocator_traits::priv_select_on_container_copy_construction(flag, a);
  339.    }
  340.  
  341.    #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  342.       //! <b>Effects</b>: calls <code>a.construct(p, std::forward<Args>(args)...)</code> if that call is well-formed;
  343.       //! otherwise, invokes <code>::new (static_cast<void*>(p)) T(std::forward<Args>(args)...)</code>
  344.       template <class T, class ...Args>
  345.       static void construct(Allocator & a, T* p, BOOST_FWD_REF(Args)... args)
  346.       {
  347.          static const bool value = ::mars_boost::move_detail::and_
  348.             < container_detail::is_not_std_allocator<Allocator>
  349.             , mars_boost::container::container_detail::has_member_function_callable_with_construct
  350.                   < Allocator, T*, Args... >
  351.             >::value;
  352.          container_detail::bool_<value> flag;
  353.          allocator_traits::priv_construct(flag, a, p, ::mars_boost::forward<Args>(args)...);
  354.       }
  355.    #endif
  356.  
  357.    //! <b>Returns</b>: <code>a.storage_is_unpropagable(p)</code> if is_partially_propagable::value is true; otherwise,
  358.    //! <code>false</code>.
  359.    static bool storage_is_unpropagable(const Allocator &a, pointer p) BOOST_NOEXCEPT_OR_NOTHROW
  360.    {
  361.       container_detail::bool_<is_partially_propagable::value> flag;
  362.       return allocator_traits::priv_storage_is_unpropagable(flag, a, p);
  363.    }
  364.  
  365.    //! <b>Returns</b>: <code>true</code> if <code>is_always_equal::value == true</code>, otherwise,
  366.    //! <code>a == b</code>.
  367.    static bool equal(const Allocator &a, const Allocator &b) BOOST_NOEXCEPT_OR_NOTHROW
  368.    {
  369.       container_detail::bool_<is_always_equal::value> flag;
  370.       return allocator_traits::priv_equal(flag, a, b);
  371.    }
  372.  
  373.    #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  374.    private:
  375.    static pointer priv_allocate(container_detail::true_type, Allocator &a, size_type n, const_void_pointer p)
  376.    {  return a.allocate(n, p);  }
  377.  
  378.    static pointer priv_allocate(container_detail::false_type, Allocator &a, size_type n, const_void_pointer)
  379.    {  return a.allocate(n);  }
  380.  
  381.    template<class T>
  382.    static void priv_destroy(container_detail::true_type, Allocator &a, T* p) BOOST_NOEXCEPT_OR_NOTHROW
  383.    {  a.destroy(p);  }
  384.  
  385.    template<class T>
  386.    static void priv_destroy(container_detail::false_type, Allocator &, T* p) BOOST_NOEXCEPT_OR_NOTHROW
  387.    {  p->~T(); (void)p;  }
  388.  
  389.    static size_type priv_max_size(container_detail::true_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW
  390.    {  return a.max_size();  }
  391.  
  392.    static size_type priv_max_size(container_detail::false_type, const Allocator &) BOOST_NOEXCEPT_OR_NOTHROW
  393.    {  return size_type(-1)/sizeof(value_type);  }
  394.  
  395.    static Allocator priv_select_on_container_copy_construction(container_detail::true_type, const Allocator &a)
  396.    {  return a.select_on_container_copy_construction();  }
  397.  
  398.    static const Allocator &priv_select_on_container_copy_construction(container_detail::false_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW
  399.    {  return a;  }
  400.  
  401.    #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  402.       template<class T, class ...Args>
  403.       static void priv_construct(container_detail::true_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args)
  404.       {  a.construct( p, ::mars_boost::forward<Args>(args)...);  }
  405.  
  406.       template<class T, class ...Args>
  407.       static void priv_construct(container_detail::false_type, Allocator &, T *p, BOOST_FWD_REF(Args) ...args)
  408.       {  ::new((void*)p, boost_container_new_t()) T(::mars_boost::forward<Args>(args)...); }
  409.    #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  410.       public:
  411.  
  412.       #define BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL(N) \
  413.       template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
  414.       static void construct(Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  415.       {\
  416.          static const bool value = ::mars_boost::move_detail::and_ \
  417.             < container_detail::is_not_std_allocator<Allocator> \
  418.             , mars_boost::container::container_detail::has_member_function_callable_with_construct \
  419.                   < Allocator, T* BOOST_MOVE_I##N BOOST_MOVE_FWD_T##N > \
  420.             >::value; \
  421.          container_detail::bool_<value> flag;\
  422.          (priv_construct)(flag, a, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
  423.       }\
  424.       //
  425.       BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL)
  426.       #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL
  427.  
  428.       private:
  429.       /////////////////////////////////
  430.       // priv_construct
  431.       /////////////////////////////////
  432.       #define BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL(N) \
  433.       template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
  434.       static void priv_construct(container_detail::true_type, Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  435.       {  a.construct( p BOOST_MOVE_I##N BOOST_MOVE_FWD##N );  }\
  436.       \
  437.       template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
  438.       static void priv_construct(container_detail::false_type, Allocator &, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  439.       {  ::new((void*)p, boost_container_new_t()) T(BOOST_MOVE_FWD##N); }\
  440.       //
  441.       BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL)
  442.       #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL
  443.  
  444.    #endif   // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  445.  
  446.    template<class T>
  447.    static void priv_construct(container_detail::false_type, Allocator &, T *p, const ::mars_boost::container::default_init_t&)
  448.    {  ::new((void*)p, boost_container_new_t()) T; }
  449.  
  450.    static bool priv_storage_is_unpropagable(container_detail::true_type, const Allocator &a, pointer p)
  451.    {  return a.storage_is_unpropagable(p);  }
  452.  
  453.    static bool priv_storage_is_unpropagable(container_detail::false_type, const Allocator &, pointer)
  454.    {  return false;  }
  455.  
  456.    static bool priv_equal(container_detail::true_type,  const Allocator &, const Allocator &)
  457.    {  return true;  }
  458.  
  459.    static bool priv_equal(container_detail::false_type, const Allocator &a, const Allocator &b)
  460.    {  return a == b;  }
  461.  
  462.    #endif   //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  463. };
  464.  
  465. }  //namespace container {
  466. }  //namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  467.  
  468. #include <boost/container/detail/config_end.hpp>
  469.  
  470. #endif // ! defined(BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP)
  471.  
downloadallocator_traits.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top