diff --git a/bench/detail/varray_util.hpp b/bench/detail/varray_util.hpp index 4f5540a..d76d13f 100644 --- a/bench/detail/varray_util.hpp +++ b/bench/detail/varray_util.hpp @@ -29,11 +29,13 @@ #include #include #include +#include #include #include #include -#include +#include +#include #include // TODO - move vectors iterators optimization to the other, optional file instead of checking defines? diff --git a/bench/varray.hpp b/bench/varray.hpp index b1b916a..9840e61 100644 --- a/bench/varray.hpp +++ b/bench/varray.hpp @@ -18,7 +18,7 @@ #include #include "detail/varray.hpp" -#include +#include namespace boost { namespace container { diff --git a/include/boost/container/adaptive_pool.hpp b/include/boost/container/adaptive_pool.hpp index 519ec8a..c12d511 100644 --- a/include/boost/container/adaptive_pool.hpp +++ b/include/boost/container/adaptive_pool.hpp @@ -26,14 +26,16 @@ #include #include +#include + #include #include #include -#include +#include #include #include #include -#include + namespace boost { namespace container { diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp index a1596ba..d577df1 100644 --- a/include/boost/container/allocator_traits.hpp +++ b/include/boost/container/allocator_traits.hpp @@ -27,19 +27,21 @@ #include #include #include -#include #include +#include #include -#include //numeric_limits<>::max() -#include //placement new -#include //std::allocator #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) #include #endif + + namespace boost { namespace container { +namespace allocator_traits_detail { + +} #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -159,15 +161,15 @@ struct allocator_traits size_type; //propagate_on_container_copy_assignment typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, - propagate_on_container_copy_assignment, boost::false_type) + propagate_on_container_copy_assignment, container_detail::false_type) propagate_on_container_copy_assignment; //propagate_on_container_move_assignment typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, - propagate_on_container_move_assignment, boost::false_type) + propagate_on_container_move_assignment, container_detail::false_type) propagate_on_container_move_assignment; //propagate_on_container_swap typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Alloc, - propagate_on_container_swap, boost::false_type) + propagate_on_container_swap, container_detail::false_type) propagate_on_container_swap; #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) @@ -225,7 +227,7 @@ struct allocator_traits const bool value = boost::container::container_detail:: has_member_function_callable_with_allocate ::value; - ::boost::integral_constant flag; + container_detail::bool_ flag; return allocator_traits::priv_allocate(flag, a, n, p); } @@ -238,7 +240,7 @@ struct allocator_traits const bool value = boost::container::container_detail:: has_member_function_callable_with_destroy ::value; - ::boost::integral_constant flag; + container_detail::bool_ flag; allocator_traits::priv_destroy(flag, a, p); } @@ -249,7 +251,7 @@ struct allocator_traits const bool value = boost::container::container_detail:: has_member_function_callable_with_max_size ::value; - ::boost::integral_constant flag; + container_detail::bool_ flag; return allocator_traits::priv_max_size(flag, a); } @@ -272,7 +274,7 @@ struct allocator_traits const bool value = boost::container::container_detail:: has_member_function_callable_with_select_on_container_copy_construction ::value; - ::boost::integral_constant flag; + container_detail::bool_ flag; return allocator_traits::priv_select_on_container_copy_construction(flag, a); } @@ -282,63 +284,63 @@ struct allocator_traits template static void construct(Alloc & a, T* p, BOOST_FWD_REF(Args)... args) { - ::boost::integral_constant::value> flag; + container_detail::bool_::value> flag; allocator_traits::priv_construct(flag, a, p, ::boost::forward(args)...); } #endif #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) private: - static pointer priv_allocate(boost::true_type, Alloc &a, size_type n, const_void_pointer p) + static pointer priv_allocate(container_detail::true_type, Alloc &a, size_type n, const_void_pointer p) { return a.allocate(n, p); } - static pointer priv_allocate(boost::false_type, Alloc &a, size_type n, const_void_pointer) + static pointer priv_allocate(container_detail::false_type, Alloc &a, size_type n, const_void_pointer) { return allocator_traits::allocate(a, n); } template - static void priv_destroy(boost::true_type, Alloc &a, T* p) BOOST_CONTAINER_NOEXCEPT + static void priv_destroy(container_detail::true_type, Alloc &a, T* p) BOOST_CONTAINER_NOEXCEPT { a.destroy(p); } template - static void priv_destroy(boost::false_type, Alloc &, T* p) BOOST_CONTAINER_NOEXCEPT + static void priv_destroy(container_detail::false_type, Alloc &, T* p) BOOST_CONTAINER_NOEXCEPT { p->~T(); (void)p; } - static size_type priv_max_size(boost::true_type, const Alloc &a) BOOST_CONTAINER_NOEXCEPT + static size_type priv_max_size(container_detail::true_type, const Alloc &a) BOOST_CONTAINER_NOEXCEPT { return a.max_size(); } - static size_type priv_max_size(boost::false_type, const Alloc &) BOOST_CONTAINER_NOEXCEPT - { return (std::numeric_limits::max)(); } + static size_type priv_max_size(container_detail::false_type, const Alloc &) BOOST_CONTAINER_NOEXCEPT + { return size_type(-1); } - static Alloc priv_select_on_container_copy_construction(boost::true_type, const Alloc &a) + static Alloc priv_select_on_container_copy_construction(container_detail::true_type, const Alloc &a) { return a.select_on_container_copy_construction(); } - static const Alloc &priv_select_on_container_copy_construction(boost::false_type, const Alloc &a) BOOST_CONTAINER_NOEXCEPT + static const Alloc &priv_select_on_container_copy_construction(container_detail::false_type, const Alloc &a) BOOST_CONTAINER_NOEXCEPT { return a; } #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template - static void priv_construct(boost::false_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) + static void priv_construct(container_detail::false_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) { const bool value = boost::container::container_detail:: has_member_function_callable_with_construct < Alloc, T*, Args... >::value; - ::boost::integral_constant flag; + container_detail::bool_ flag; priv_construct_dispatch2(flag, a, p, ::boost::forward(args)...); } template - static void priv_construct(boost::true_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) + static void priv_construct(container_detail::true_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) { - priv_construct_dispatch2(boost::false_type(), a, p, ::boost::forward(args)...); + priv_construct_dispatch2(container_detail::false_type(), a, p, ::boost::forward(args)...); } template - static void priv_construct_dispatch2(boost::true_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) + static void priv_construct_dispatch2(container_detail::true_type, Alloc &a, T *p, BOOST_FWD_REF(Args) ...args) { a.construct( p, ::boost::forward(args)...); } template - static void priv_construct_dispatch2(boost::false_type, Alloc &, T *p, BOOST_FWD_REF(Args) ...args) - { ::new((void*)p) T(::boost::forward(args)...); } + static void priv_construct_dispatch2(container_detail::false_type, Alloc &, T *p, BOOST_FWD_REF(Args) ...args) + { ::new((void*)p, boost_container_new_t()) T(::boost::forward(args)...); } #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) public: #define BOOST_PP_LOCAL_MACRO(n) \ @@ -346,7 +348,8 @@ struct allocator_traits static void construct(Alloc &a, T *p \ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ - ::boost::integral_constant::value> flag; \ + container_detail::bool_ \ + ::value> flag; \ allocator_traits::priv_construct(flag, a, p \ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ } \ @@ -357,41 +360,41 @@ struct allocator_traits private: #define BOOST_PP_LOCAL_MACRO(n) \ template \ - static void priv_construct(boost::false_type, Alloc &a, T *p \ + static void priv_construct(container_detail::false_type, Alloc &a, T *p \ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ { \ const bool value = \ boost::container::container_detail::has_member_function_callable_with_construct \ < Alloc, T* BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_FWD_TYPE, _) >::value; \ - ::boost::integral_constant flag; \ + container_detail::bool_ flag; \ priv_construct_dispatch2(flag, a, p \ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ } \ \ template \ - static void priv_construct(boost::true_type, Alloc &a, T *p \ + static void priv_construct(container_detail::true_type, Alloc &a, T *p \ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ { \ - priv_construct_dispatch2(boost::false_type(), a, p \ + priv_construct_dispatch2(container_detail::false_type(), a, p \ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ } \ \ template \ - static void priv_construct_dispatch2(boost::true_type, Alloc &a, T *p \ + static void priv_construct_dispatch2(container_detail::true_type, Alloc &a, T *p \ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST,_)) \ { a.construct( p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); } \ \ template \ - static void priv_construct_dispatch2(boost::false_type, Alloc &, T *p \ + static void priv_construct_dispatch2(container_detail::false_type, Alloc &, T *p \ BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _) ) \ - { ::new((void*)p) T(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); } \ + { ::new((void*)p, boost_container_new_t()) T(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); }\ // #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) #include BOOST_PP_LOCAL_ITERATE() #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template - static void priv_construct_dispatch2(boost::false_type, Alloc &, T *p, ::boost::container::default_init_t) + static void priv_construct_dispatch2(container_detail::false_type, Alloc &, T *p, ::boost::container::default_init_t) { ::new((void*)p) T; } #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) diff --git a/include/boost/container/container_fwd.hpp b/include/boost/container/container_fwd.hpp index 415de0f..db7a67f 100644 --- a/include/boost/container/container_fwd.hpp +++ b/include/boost/container/container_fwd.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2005-2014. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -59,11 +59,46 @@ namespace bi = boost::intrusive; }}} #include -#include -#include -#include -#include -#include + +# if defined(__clang__) && defined(_LIBCPP_VERSION) + #define BOOST_CONTAINER_CLANG_INLINE_STD_NS + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wc++11-extensions" + + #define BOOST_CONTAINER_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD + #define BOOST_CONTAINER_STD_NS_END _LIBCPP_END_NAMESPACE_STD + +#endif + +#if !defined(BOOST_CONTAINER_STD_NS_BEG) + + #define BOOST_CONTAINER_STD_NS_BEG namespace std{ + #define BOOST_CONTAINER_STD_NS_END } + +#endif + +BOOST_CONTAINER_STD_NS_BEG + +template +class allocator; + +template +struct less; + +template +struct pair; + +template +struct char_traits; + +BOOST_CONTAINER_STD_NS_END + +#ifdef BOOST_CONTAINER_CLANG_INLINE_STD_NS + +#pragma GCC diagnostic pop +#undef BOOST_CONTAINER_CLANG_INLINE_STD_NS + +#endif //BOOST_CONTAINER_CLANG_INLINE_STD_NS #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -268,6 +303,7 @@ struct dummy } //detail_really_deep_namespace { + #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED }} //namespace boost { namespace container { diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp index c5f7994..d8a546c 100644 --- a/include/boost/container/deque.hpp +++ b/include/boost/container/deque.hpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/include/boost/container/detail/adaptive_node_pool.hpp b/include/boost/container/detail/adaptive_node_pool.hpp index f776b51..4e73754 100644 --- a/include/boost/container/detail/adaptive_node_pool.hpp +++ b/include/boost/container/detail/adaptive_node_pool.hpp @@ -29,7 +29,7 @@ #include #include #include -#include + namespace boost { namespace container { diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp index 100f202..a35279d 100644 --- a/include/boost/container/detail/advanced_insert_int.hpp +++ b/include/boost/container/detail/advanced_insert_int.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include //std::iterator_traits #include #include @@ -94,7 +95,11 @@ struct insert_n_copies_proxy { boost::container::uninitialized_fill_alloc_n(a, v_, n, p); } void copy_n_and_update(A &, Iterator p, size_type n) const - { std::fill_n(p, n, v_); } + { + for (; 0 < n; --n, ++p){ + *p = v_; + } + } const value_type &v_; }; diff --git a/include/boost/container/detail/algorithms.hpp b/include/boost/container/detail/algorithms.hpp index c8477d8..af15f65 100644 --- a/include/boost/container/detail/algorithms.hpp +++ b/include/boost/container/detail/algorithms.hpp @@ -19,47 +19,15 @@ #include #include - -#include - -#include -#include +#include #include - -#include - namespace boost { namespace container { -template -struct is_value_init_construct_iterator -{ - static const bool value = false; -}; - -template -struct is_value_init_construct_iterator > -{ - static const bool value = true; -}; - -template -struct is_emplace_iterator -{ - static const bool value = false; -}; - -template -struct is_emplace_iterator > -{ - static const bool value = true; -}; - template inline void construct_in_place(A &a, T* dest, InpIt source) { boost::container::allocator_traits::construct(a, dest, *source); } -//#endif template inline void construct_in_place(A &a, T *dest, value_init_construct_iterator) @@ -67,12 +35,18 @@ inline void construct_in_place(A &a, T *dest, value_init_construct_iterator::construct(a, dest); } +template +class default_init_construct_iterator; + template inline void construct_in_place(A &a, T *dest, default_init_construct_iterator) { boost::container::allocator_traits::construct(a, dest, default_init); } +template +class emplace_iterator; + template inline void construct_in_place(A &a, T *dest, emplace_iterator ei) { diff --git a/include/boost/container/detail/config_begin.hpp b/include/boost/container/detail/config_begin.hpp index 7601ca2..ca9dd59 100644 --- a/include/boost/container/detail/config_begin.hpp +++ b/include/boost/container/detail/config_begin.hpp @@ -9,7 +9,9 @@ ////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_CONTAINER_CONTAINER_DETAIL_CONFIG_INCLUDED #define BOOST_CONTAINER_CONTAINER_DETAIL_CONFIG_INCLUDED +#ifndef BOOST_CONFIG_HPP #include +#endif #endif //BOOST_CONTAINER_CONTAINER_DETAIL_CONFIG_INCLUDED diff --git a/include/boost/container/detail/iterators.hpp b/include/boost/container/detail/iterators.hpp index b372197..0dabd3c 100644 --- a/include/boost/container/detail/iterators.hpp +++ b/include/boost/container/detail/iterators.hpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #ifdef BOOST_CONTAINER_PERFECT_FORWARDING #include @@ -148,7 +148,7 @@ class constant_iterator { return m_num - other.m_num; } }; -template +template class value_init_construct_iterator : public std::iterator @@ -259,7 +259,7 @@ class value_init_construct_iterator { return m_num - other.m_num; } }; -template +template class default_init_construct_iterator : public std::iterator diff --git a/include/boost/container/detail/node_alloc_holder.hpp b/include/boost/container/detail/node_alloc_holder.hpp index c3ebb00..68cc42b 100644 --- a/include/boost/container/detail/node_alloc_holder.hpp +++ b/include/boost/container/detail/node_alloc_holder.hpp @@ -34,13 +34,14 @@ #include #include #include +#include #ifndef BOOST_CONTAINER_PERFECT_FORWARDING #include #endif #include -#include + namespace boost { @@ -189,7 +190,7 @@ struct node_alloc_holder node_deallocator.release(); //This does not throw typedef typename Node::hook_type hook_type; - ::new(static_cast(container_detail::to_raw_pointer(p))) hook_type; + ::new(static_cast(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; return (p); } @@ -207,7 +208,7 @@ struct node_alloc_holder BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ node_deallocator.release(); \ typedef typename Node::hook_type hook_type; \ - ::new(static_cast(container_detail::to_raw_pointer(p))) hook_type; \ + ::new(static_cast(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; \ return (p); \ } \ //! @@ -225,7 +226,7 @@ struct node_alloc_holder node_deallocator.release(); //This does not throw typedef typename Node::hook_type hook_type; - ::new(static_cast(container_detail::to_raw_pointer(p))) hook_type; + ::new(static_cast(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; return (p); } @@ -270,7 +271,7 @@ struct node_alloc_holder ++beg; //This does not throw typedef typename Node::hook_type hook_type; - ::new(static_cast(p)) hook_type; + ::new(static_cast(p), boost_container_new_t()) hook_type; //This can throw in some containers (predicate might throw). //(sdestructor will destruct the node and node_deallocator will deallocate it in case of exception) inserter(*p); diff --git a/include/boost/container/detail/node_pool.hpp b/include/boost/container/detail/node_pool.hpp index 56c3d8a..60d8266 100644 --- a/include/boost/container/detail/node_pool.hpp +++ b/include/boost/container/detail/node_pool.hpp @@ -23,9 +23,8 @@ #include #include #include -#include +#include #include -#include #include //std::unary_function #include //std::swap #include diff --git a/include/boost/container/detail/placement_new.hpp b/include/boost/container/detail/placement_new.hpp new file mode 100644 index 0000000..2489d8a --- /dev/null +++ b/include/boost/container/detail/placement_new.hpp @@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP +#define BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP + +#if defined(_MSC_VER) +# pragma once +#endif + +struct boost_container_new_t{}; + +//avoid including +inline void *operator new(std::size_t, void *p, boost_container_new_t) +{ return p; } + +inline void operator delete(void *, void *, boost_container_new_t) +{} + +#endif //BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP diff --git a/include/boost/container/detail/pool_common.hpp b/include/boost/container/detail/pool_common.hpp index 53a7427..11fb6c2 100644 --- a/include/boost/container/detail/pool_common.hpp +++ b/include/boost/container/detail/pool_common.hpp @@ -19,7 +19,6 @@ #include #include -#include namespace boost { namespace container { diff --git a/include/boost/container/detail/preprocessor.hpp b/include/boost/container/detail/preprocessor.hpp index 3f25417..9cae499 100644 --- a/include/boost/container/detail/preprocessor.hpp +++ b/include/boost/container/detail/preprocessor.hpp @@ -39,7 +39,6 @@ #include #include #include -#include #define BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS 10 diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp index afe7d9f..eeac7d1 100644 --- a/include/boost/container/detail/utilities.hpp +++ b/include/boost/container/detail/utilities.hpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include //std::distance @@ -78,14 +77,14 @@ swap_dispatch(T &left, T &right) //swap using member swap template inline typename container_detail::enable_if_c - ::value && boost::has_move_emulation_enabled::value, void>::type + ::value/* && boost::has_move_emulation_enabled::value*/, void>::type swap_dispatch(T &left, T &right) { T temp(boost::move(left)); // may throw left = boost::move(right); // may throw right = boost::move(temp); // may throw } - +/* template inline typename container_detail::enable_if_c ::value && !boost::has_move_emulation_enabled::value, void>::type @@ -94,7 +93,7 @@ typename container_detail::enable_if_c using std::swap; swap(left, right); // may throw } - +*/ namespace container_detail { template diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp index 0b99e1e..33cc6ee 100644 --- a/include/boost/container/list.hpp +++ b/include/boost/container/list.hpp @@ -199,8 +199,8 @@ class list typedef BOOST_CONTAINER_IMPDEF(NodeAlloc) stored_allocator_type; typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator; typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator; - typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) reverse_iterator; - typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) const_reverse_iterator; + typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) reverse_iterator; + typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) const_reverse_iterator; ////////////////////////////////////////////// // diff --git a/include/boost/container/node_allocator.hpp b/include/boost/container/node_allocator.hpp index 249a640..8004339 100644 --- a/include/boost/container/node_allocator.hpp +++ b/include/boost/container/node_allocator.hpp @@ -31,7 +31,6 @@ #include #include #include -#include namespace boost { namespace container { diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index 97c105c..b8b4157 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -40,10 +40,11 @@ #include #include #include -#include //max +#include +#include + #include -#include //placement new #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED @@ -1825,7 +1826,7 @@ class stable_vector , container_detail::addressof(p->value) , it); //This does not throw - ::new(static_cast(container_detail::to_raw_pointer(p))) + ::new(static_cast(container_detail::to_raw_pointer(p)), boost_container_new_t()) node_base_type(index_traits_type::ptr_to_node_base_ptr(*up_index)); } @@ -1838,7 +1839,7 @@ class stable_vector , container_detail::addressof(p->value) , ::boost::forward(value_convertible)); //This does not throw - ::new(static_cast(container_detail::to_raw_pointer(p))) node_base_type; + ::new(static_cast(container_detail::to_raw_pointer(p)), boost_container_new_t()) node_base_type; } void priv_swap_members(stable_vector &x) diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index 784203e..765a2c6 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2005-2014. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -19,19 +19,22 @@ #include #include -#include -#include -#include -#include -#include +//#include //Already included by container_fwd.hpp +#include //for std::allocator +#include //for std::random_access_iterator_tag +#include //for std::pair,std::distance +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) +#include //for std::initializer_list +#endif + #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -41,19 +44,18 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include -#include -#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) -#include -#endif +#include + +#include +#include +#include +#include +#include +#include namespace boost { namespace container { @@ -225,31 +227,32 @@ namespace container_detail { struct uninitialized_size_t {}; static const uninitialized_size_t uninitialized_size = uninitialized_size_t(); -template -struct vector_value_traits +template +struct vector_value_traits_base { - typedef T value_type; - typedef Allocator allocator_type; - static const bool trivial_dctr = boost::has_trivial_destructor::value; - static const bool trivial_dctr_after_move = ::boost::has_trivial_destructor_after_move::value; - static const bool trivial_copy = has_trivial_copy::value; - static const bool nothrow_copy = has_nothrow_copy::value || trivial_copy; - static const bool trivial_assign = has_trivial_assign::value; - static const bool nothrow_assign = has_nothrow_assign::value || trivial_assign; + static const bool trivial_dctr = boost::has_trivial_destructor::value; + static const bool trivial_dctr_after_move = ::boost::has_trivial_destructor_after_move::value; + static const bool trivial_copy = has_trivial_copy::value; + static const bool nothrow_copy = has_nothrow_copy::value || trivial_copy; + static const bool trivial_assign = has_trivial_assign::value; + static const bool nothrow_assign = has_nothrow_assign::value || trivial_assign; +}; + +template +struct vector_value_traits + : public vector_value_traits_base +{ + typedef vector_value_traits_base base_t; //This is the anti-exception array destructor //to deallocate values already constructed typedef typename container_detail::if_c - ,container_detail::scoped_destructor_n >::type ArrayDestructor; //This is the anti-exception array deallocator - typedef typename container_detail::if_c - - ,container_detail::scoped_array_deallocator - >::type ArrayDeallocator; + typedef container_detail::scoped_array_deallocator ArrayDeallocator; }; //!This struct deallocates and allocated memory @@ -569,13 +572,13 @@ class vector typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator; typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator; #endif - typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) reverse_iterator; - typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) const_reverse_iterator; + typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) reverse_iterator; + typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator) const_reverse_iterator; #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED private: BOOST_COPYABLE_AND_MOVABLE(vector) - typedef container_detail::vector_value_traits value_traits; + typedef container_detail::vector_value_traits value_traits; typedef container_detail::integral_constant allocator_v0; typedef container_detail::integral_constant allocator_v1; @@ -1395,7 +1398,7 @@ class vector template void emplace_back(Args &&...args) { - if (this->m_holder.m_size < this->m_holder.capacity()){ + if (BOOST_LIKELY(this->m_holder.m_size < this->m_holder.capacity())){ T* const back_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; //There is more memory, just construct a new object at the end allocator_traits_type::construct(this->m_holder.alloc(), back_pos, ::boost::forward(args)...); @@ -1435,7 +1438,7 @@ class vector { \ T* const back_pos = container_detail::to_raw_pointer \ (this->m_holder.start()) + this->m_holder.m_size; \ - if (this->m_holder.m_size < this->m_holder.capacity()){ \ + if (BOOST_LIKELY(this->m_holder.m_size < this->m_holder.capacity())){ \ allocator_traits_type::construct (this->m_holder.alloc() \ , back_pos BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); \ ++this->m_holder.m_size; \ @@ -1698,7 +1701,21 @@ class vector //! //! Complexity: Linear to the number of elements in the container. friend bool operator==(const vector& x, const vector& y) - { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); } + { + if(x.size() != y.size()){ + return false; + } + else{ + const_iterator first1(x.cbegin()), first2(y.cbegin()); + const const_iterator last1(x.cend()); + for (; first1 != last1; ++first1, ++first2) { + if (!(*first1 != *first2)) { + return false; + } + } + return true; + } + } //! Effects: Returns true if x and y are unequal //! @@ -1710,7 +1727,15 @@ class vector //! //! Complexity: Linear to the number of elements in the container. friend bool operator<(const vector& x, const vector& y) - { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } + { + const_iterator first1(x.cbegin()), first2(y.cbegin()); + const const_iterator last1(x.cend()), last2(y.cend()); + for ( ; (first1 != last1) && (first2 != last2); ++first1, ++first2 ) { + if (*first1 < *first2) return true; + if (*first2 < *first1) return false; + } + return (first1 == last1) && (first2 != last2); + } //! Effects: Returns true if x is greater than y //! @@ -1843,7 +1868,7 @@ class vector bool stable_emplace_back(Args &&...args) { const bool room_enough = this->m_holder.m_size < this->m_holder.capacity(); - if (room_enough){ + if (BOOST_LIKELY(room_enough)){ T* const back_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size; //There is more memory, just construct a new object at the end allocator_traits_type::construct(this->m_holder.alloc(), back_pos, ::boost::forward(args)...); @@ -1859,7 +1884,7 @@ class vector bool stable_emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ const bool room_enough = this->m_holder.m_size < this->m_holder.capacity(); \ - if (room_enough){ \ + if (BOOST_LIKELY(room_enough)){ \ T* const back_pos = container_detail::to_raw_pointer \ (this->m_holder.start()) + this->m_holder.m_size; \ allocator_traits_type::construct (this->m_holder.alloc() \ @@ -2089,7 +2114,7 @@ class vector template void priv_push_back(BOOST_FWD_REF(U) u) { - if (this->m_holder.m_size < this->m_holder.capacity()){ + if (BOOST_LIKELY(this->m_holder.m_size < this->m_holder.capacity())){ //There is more memory, just construct a new object at the end allocator_traits_type::construct ( this->m_holder.alloc() @@ -2928,14 +2953,14 @@ class vector namespace boost { - +/* //!has_trivial_destructor_after_move<> == true_type //!specialization for optimizations template struct has_trivial_destructor_after_move > : public ::boost::has_trivial_destructor_after_move {}; - +*/ } //#define BOOST_CONTAINER_PUT_SWAP_OVERLOAD_IN_NAMESPACE_STD diff --git a/proj/vc7ide/container.vcproj b/proj/vc7ide/container.vcproj index d1fc88e..7d606ea 100644 --- a/proj/vc7ide/container.vcproj +++ b/proj/vc7ide/container.vcproj @@ -1,399 +1,402 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + ProjectType="Visual C++" + Version="7.10" + Name="_containerlib" + ProjectGUID="{FF56BAF1-32EC-4B22-B6BD-95A3A67C3135}" + Keyword="Win32Proj"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proj/vc7ide/vector_test.vcproj b/proj/vc7ide/vector_test.vcproj index af7b6af..68e9a83 100644 --- a/proj/vc7ide/vector_test.vcproj +++ b/proj/vc7ide/vector_test.vcproj @@ -1,136 +1,135 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/alloc_full_test.cpp b/test/alloc_full_test.cpp index fef26ba..a283552 100644 --- a/test/alloc_full_test.cpp +++ b/test/alloc_full_test.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include #include //std::remove diff --git a/test/pair_test.cpp b/test/pair_test.cpp index 3560b74..dbfdb06 100644 --- a/test/pair_test.cpp +++ b/test/pair_test.cpp @@ -11,7 +11,7 @@ #include #include "movable_int.hpp" #include "emplace_test.hpp" -#include +#include //non_copymovable_int //copyable_int