diff --git a/bench/bench_static_vector.cpp b/bench/bench_static_vector.cpp index bfcc4de..4553dc7 100644 --- a/bench/bench_static_vector.cpp +++ b/bench/bench_static_vector.cpp @@ -4,8 +4,8 @@ // @date Aug 14, 2011 // @author Andrew Hundt // -// (C) 2011-2013 Andrew Hundt -// (C) 2013-2013 Ion Gaztanaga +// (C) Copyright 2011-2013 Andrew Hundt +// (C) Copyright 2013-2013 Ion Gaztanaga // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at diff --git a/doc/container.qbk b/doc/container.qbk index 9fc605e..aa43fe7 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -549,7 +549,7 @@ shortly after new elements are added to the container. [*Boost.Container] offers two new members for `vector`, `static_vector` and `stable_vector`: `explicit container::container(size_type n, default_init_t)` and -`explicit container::resize(size_type n, default_init_t)`, where new elements are constructed +`container::resize(size_type n, default_init_t)`, where new elements are constructed using [@http://en.cppreference.com/w/cpp/language/default_initialization default initialization]. [endsect] @@ -1213,6 +1213,14 @@ use [*Boost.Container]? There are several reasons for that: [section:release_notes Release Notes] + +[section:release_notes_boost_1_64_00 Boost 1.64 Release] + +* Fixed bugs: + * [@https://svn.boost.org/trac/boost/ticket/12749 Trac #12749 : ['"container::pmr::polymorphic_allocator compilation error"]]. + +[endsect] + [section:release_notes_boost_1_63_00 Boost 1.63 Release] * Fixed bugs: diff --git a/include/boost/container/allocator_traits.hpp b/include/boost/container/allocator_traits.hpp index e6a882e..d6621f6 100644 --- a/include/boost/container/allocator_traits.hpp +++ b/include/boost/container/allocator_traits.hpp @@ -289,18 +289,18 @@ struct allocator_traits //! Returns: a.allocate(n) //! - static pointer allocate(Allocator &a, size_type n) + BOOST_CONTAINER_FORCEINLINE static pointer allocate(Allocator &a, size_type n) { return a.allocate(n); } //! Returns: a.deallocate(p, n) //! //! Throws: Nothing - static void deallocate(Allocator &a, pointer p, size_type n) + BOOST_CONTAINER_FORCEINLINE static void deallocate(Allocator &a, pointer p, size_type n) { a.deallocate(p, n); } //! Effects: calls a.allocate(n, p) if that call is well-formed; //! otherwise, invokes a.allocate(n) - static pointer allocate(Allocator &a, size_type n, const_void_pointer p) + BOOST_CONTAINER_FORCEINLINE static pointer allocate(Allocator &a, size_type n, const_void_pointer p) { const bool value = boost::container::container_detail:: has_member_function_callable_with_allocate @@ -312,7 +312,7 @@ struct allocator_traits //! Effects: calls a.destroy(p) if that call is well-formed; //! otherwise, invokes p->~T(). template - static void destroy(Allocator &a, T*p) BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE static void destroy(Allocator &a, T*p) BOOST_NOEXCEPT_OR_NOTHROW { typedef T* destroy_pointer; const bool value = boost::container::container_detail:: @@ -324,7 +324,7 @@ struct allocator_traits //! Returns: a.max_size() if that expression is well-formed; otherwise, //! numeric_limits::max(). - static size_type max_size(const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE static size_type max_size(const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW { const bool value = allocator_traits_detail::has_max_size::value; container_detail::bool_ flag; @@ -333,7 +333,7 @@ struct allocator_traits //! Returns: a.select_on_container_copy_construction() if that expression is well-formed; //! otherwise, a. - static BOOST_CONTAINER_DOC1ST(Allocator, + BOOST_CONTAINER_FORCEINLINE static BOOST_CONTAINER_DOC1ST(Allocator, typename container_detail::if_c < allocator_traits_detail::has_select_on_container_copy_construction::value BOOST_MOVE_I Allocator BOOST_MOVE_I const Allocator & >::type) @@ -349,7 +349,7 @@ struct allocator_traits //! Effects: calls a.construct(p, std::forward(args)...) if that call is well-formed; //! otherwise, invokes ::new (static_cast(p)) T(std::forward(args)...) template - static void construct(Allocator & a, T* p, BOOST_FWD_REF(Args)... args) + BOOST_CONTAINER_FORCEINLINE static void construct(Allocator & a, T* p, BOOST_FWD_REF(Args)... args) { static const bool value = ::boost::move_detail::and_ < container_detail::is_not_std_allocator @@ -363,7 +363,7 @@ struct allocator_traits //! Returns: a.storage_is_unpropagable(p) if is_partially_propagable::value is true; otherwise, //! false. - static bool storage_is_unpropagable(const Allocator &a, pointer p) BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE static bool storage_is_unpropagable(const Allocator &a, pointer p) BOOST_NOEXCEPT_OR_NOTHROW { container_detail::bool_ flag; return allocator_traits::priv_storage_is_unpropagable(flag, a, p); @@ -371,7 +371,7 @@ struct allocator_traits //! Returns: true if is_always_equal::value == true, otherwise, //! a == b. - static bool equal(const Allocator &a, const Allocator &b) BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE static bool equal(const Allocator &a, const Allocator &b) BOOST_NOEXCEPT_OR_NOTHROW { container_detail::bool_ flag; return allocator_traits::priv_equal(flag, a, b); @@ -379,46 +379,46 @@ struct allocator_traits #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) private: - static pointer priv_allocate(container_detail::true_type, Allocator &a, size_type n, const_void_pointer p) + BOOST_CONTAINER_FORCEINLINE static pointer priv_allocate(container_detail::true_type, Allocator &a, size_type n, const_void_pointer p) { return a.allocate(n, p); } - static pointer priv_allocate(container_detail::false_type, Allocator &a, size_type n, const_void_pointer) + BOOST_CONTAINER_FORCEINLINE static pointer priv_allocate(container_detail::false_type, Allocator &a, size_type n, const_void_pointer) { return a.allocate(n); } template - static void priv_destroy(container_detail::true_type, Allocator &a, T* p) BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE static void priv_destroy(container_detail::true_type, Allocator &a, T* p) BOOST_NOEXCEPT_OR_NOTHROW { a.destroy(p); } template - static void priv_destroy(container_detail::false_type, Allocator &, T* p) BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE static void priv_destroy(container_detail::false_type, Allocator &, T* p) BOOST_NOEXCEPT_OR_NOTHROW { p->~T(); (void)p; } - static size_type priv_max_size(container_detail::true_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE static size_type priv_max_size(container_detail::true_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW { return a.max_size(); } - static size_type priv_max_size(container_detail::false_type, const Allocator &) BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE static size_type priv_max_size(container_detail::false_type, const Allocator &) BOOST_NOEXCEPT_OR_NOTHROW { return size_type(-1)/sizeof(value_type); } - static Allocator priv_select_on_container_copy_construction(container_detail::true_type, const Allocator &a) + BOOST_CONTAINER_FORCEINLINE static Allocator priv_select_on_container_copy_construction(container_detail::true_type, const Allocator &a) { return a.select_on_container_copy_construction(); } - static const Allocator &priv_select_on_container_copy_construction(container_detail::false_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW + BOOST_CONTAINER_FORCEINLINE static const Allocator &priv_select_on_container_copy_construction(container_detail::false_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW { return a; } #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template - static void priv_construct(container_detail::true_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args) + BOOST_CONTAINER_FORCEINLINE static void priv_construct(container_detail::true_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args) { a.construct( p, ::boost::forward(args)...); } template - static void priv_construct(container_detail::false_type, Allocator &, T *p, BOOST_FWD_REF(Args) ...args) + BOOST_CONTAINER_FORCEINLINE static void priv_construct(container_detail::false_type, Allocator &, 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_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL(N) \ template\ - static void construct(Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE static void construct(Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ {\ static const bool value = ::boost::move_detail::and_ \ < container_detail::is_not_std_allocator \ @@ -438,11 +438,11 @@ struct allocator_traits ///////////////////////////////// #define BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL(N) \ template\ - static void priv_construct(container_detail::true_type, Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE static void priv_construct(container_detail::true_type, Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ { a.construct( p BOOST_MOVE_I##N BOOST_MOVE_FWD##N ); }\ \ template\ - static void priv_construct(container_detail::false_type, Allocator &, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + BOOST_CONTAINER_FORCEINLINE static void priv_construct(container_detail::false_type, Allocator &, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ { ::new((void*)p, boost_container_new_t()) T(BOOST_MOVE_FWD##N); }\ // BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL) @@ -451,19 +451,19 @@ struct allocator_traits #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template - static void priv_construct(container_detail::false_type, Allocator &, T *p, const ::boost::container::default_init_t&) + BOOST_CONTAINER_FORCEINLINE static void priv_construct(container_detail::false_type, Allocator &, T *p, const ::boost::container::default_init_t&) { ::new((void*)p, boost_container_new_t()) T; } - static bool priv_storage_is_unpropagable(container_detail::true_type, const Allocator &a, pointer p) + BOOST_CONTAINER_FORCEINLINE static bool priv_storage_is_unpropagable(container_detail::true_type, const Allocator &a, pointer p) { return a.storage_is_unpropagable(p); } - static bool priv_storage_is_unpropagable(container_detail::false_type, const Allocator &, pointer) + BOOST_CONTAINER_FORCEINLINE static bool priv_storage_is_unpropagable(container_detail::false_type, const Allocator &, pointer) { return false; } - static bool priv_equal(container_detail::true_type, const Allocator &, const Allocator &) + BOOST_CONTAINER_FORCEINLINE static bool priv_equal(container_detail::true_type, const Allocator &, const Allocator &) { return true; } - static bool priv_equal(container_detail::false_type, const Allocator &a, const Allocator &b) + BOOST_CONTAINER_FORCEINLINE static bool priv_equal(container_detail::false_type, const Allocator &a, const Allocator &b) { return a == b; } #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) diff --git a/include/boost/container/detail/advanced_insert_int.hpp b/include/boost/container/detail/advanced_insert_int.hpp index 278cd1b..1050857 100644 --- a/include/boost/container/detail/advanced_insert_int.hpp +++ b/include/boost/container/detail/advanced_insert_int.hpp @@ -107,8 +107,8 @@ struct insert_n_copies_proxy void copy_n_and_update(Allocator &, Iterator p, size_type n) const { - for (; 0 < n; --n, ++p){ - *p = v_; + for (; 0 < n; --n, ++p){ + *p = v_; } } diff --git a/include/boost/container/detail/dispatch_uses_allocator.hpp b/include/boost/container/detail/dispatch_uses_allocator.hpp index fdf203c..946fdf6 100644 --- a/include/boost/container/detail/dispatch_uses_allocator.hpp +++ b/include/boost/container/detail/dispatch_uses_allocator.hpp @@ -287,7 +287,7 @@ template< typename ConstructAlloc, typename ArgAlloc, class Pair \ , template class BoostTuple \ BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \ typename container_detail::enable_if< container_detail::is_pair >::type\ - dispatch_uses_allocator( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t\ + dispatch_uses_allocator( ConstructAlloc & construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, Pair* pair, piecewise_construct_t\ , BoostTuple p\ , BoostTuple q)\ {\ @@ -313,7 +313,7 @@ BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BO template< typename ConstructAlloc, typename ArgAlloc, class Pair , template class Tuple, class... Args1, class... Args2, size_t... Indexes1, size_t... Indexes2> - void dispatch_uses_allocator_index( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair + void dispatch_uses_allocator_index( ConstructAlloc & construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, Pair* pair , Tuple& t1, Tuple& t2, index_tuple, index_tuple) { (void)t1; (void)t2; @@ -331,7 +331,7 @@ BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BO template< typename ConstructAlloc, typename ArgAlloc, class Pair , template class Tuple, class... Args1, class... Args2> typename container_detail::enable_if< container_detail::is_pair >::type - dispatch_uses_allocator( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t + dispatch_uses_allocator( ConstructAlloc & construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, Pair* pair, piecewise_construct_t , Tuple t1, Tuple t2) { (dispatch_uses_allocator_index)( construct_alloc, arg_alloc, pair, t1, t2 @@ -347,7 +347,7 @@ BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BO , template class StdTuple\ BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \ typename container_detail::enable_if< container_detail::is_pair >::type\ - dispatch_uses_allocator(ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t\ + dispatch_uses_allocator(ConstructAlloc & construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, Pair* pair, piecewise_construct_t\ , StdTuple p\ , StdTuple q)\ {\ @@ -382,7 +382,7 @@ BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BO BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \ typename container_detail::enable_if< container_detail::is_pair >::type\ dispatch_uses_allocator\ - ( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t\ + ( ConstructAlloc & construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, Pair* pair, piecewise_construct_t\ , StdTuple p\ , StdTuple q)\ {\ @@ -406,6 +406,52 @@ BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BO #endif //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +template < typename ConstructAlloc + , typename ArgAlloc + , class Pair, class KeyType, class ... Args> +typename container_detail::enable_if< container_detail::is_pair, void >::type + dispatch_uses_allocator + (ConstructAlloc & construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, Pair* p, try_emplace_t, BOOST_FWD_REF(KeyType) k, BOOST_FWD_REF(Args) ...args) +{ + (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->first), ::boost::forward(k)); + BOOST_TRY{ + (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->second), ::boost::forward(args)...); + } + BOOST_CATCH(...) { + allocator_traits::destroy(construct_alloc, container_detail::addressof(p->first)); + BOOST_RETHROW + } + BOOST_CATCH_END +} + +#else + +#define BOOST_CONTAINER_DISPATCH_USES_ALLOCATOR_PAIR_TRY_EMPLACE_CODE(N) \ + template \ + inline typename container_detail::enable_if\ + < container_detail::is_pair, void >::type\ + dispatch_uses_allocator\ + (ConstructAlloc &construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, Pair* p, try_emplace_t, \ + BOOST_FWD_REF(KeyType) k BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->first), ::boost::forward(k));\ + BOOST_TRY{\ + (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->second) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + }\ + BOOST_CATCH(...) {\ + allocator_traits::destroy(construct_alloc, container_detail::addressof(p->first));\ + BOOST_RETHROW\ + }\ + BOOST_CATCH_END\ + }\ +// +BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_DISPATCH_USES_ALLOCATOR_PAIR_TRY_EMPLACE_CODE) +#undef BOOST_CONTAINER_DISPATCH_USES_ALLOCATOR_PAIR_TRY_EMPLACE_CODE + +#endif //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + } //namespace container_detail }} // namespace boost { namespace container { diff --git a/include/boost/container/detail/hash_table.hpp b/include/boost/container/detail/hash_table.hpp deleted file mode 100644 index 4bc5c90..0000000 --- a/include/boost/container/detail/hash_table.hpp +++ /dev/null @@ -1,383 +0,0 @@ -/* -template , class Pred = equal_to, - class Allocator = allocator > -class hash_set -{ -public: - // types - typedef Value key_type; - typedef key_type value_type; - typedef Hash hasher; - typedef Pred key_equal; - typedef Allocator allocator_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename allocator_traits::pointer pointer; - typedef typename allocator_traits::const_pointer const_pointer; - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::difference_type difference_type; - - typedef /unspecified/ iterator; - typedef /unspecified/ const_iterator; - typedef /unspecified/ local_iterator; - typedef /unspecified/ const_local_iterator; - - hash_set() - noexcept( - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value); - explicit hash_set(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - template - hash_set(InputIterator f, InputIterator l, - size_type n = 0, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - explicit hash_set(const allocator_type&); - hash_set(const hash_set&); - hash_set(const hash_set&, const Allocator&); - hash_set(hash_set&&) - noexcept( - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value); - hash_set(hash_set&&, const Allocator&); - hash_set(initializer_list, size_type n = 0, - const hasher& hf = hasher(), const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - ~hash_set(); - hash_set& operator=(const hash_set&); - hash_set& operator=(hash_set&&) - noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); - hash_set& operator=(initializer_list); - - allocator_type get_allocator() const noexcept; - - bool empty() const noexcept; - size_type size() const noexcept; - size_type max_size() const noexcept; - - iterator begin() noexcept; - iterator end() noexcept; - const_iterator begin() const noexcept; - const_iterator end() const noexcept; - const_iterator cbegin() const noexcept; - const_iterator cend() const noexcept; - - template - pair emplace(BOOST_FWD_REF(Args)... args); - template - iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args); - pair insert(const value_type& obj); - pair insert(value_type&& obj); - iterator insert(const_iterator hint, const value_type& obj); - iterator insert(const_iterator hint, value_type&& obj); - template - void insert(InputIterator first, InputIterator last); - void insert(initializer_list); - - iterator erase(const_iterator position); - size_type erase(const key_type& k); - iterator erase(const_iterator first, const_iterator last); - void clear() noexcept; - - void swap(hash_set&) - noexcept( - (!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value) && - __is_nothrow_swappable::value && - __is_nothrow_swappable::value); - - hasher hash_function() const; - key_equal key_eq() const; - - iterator find(const key_type& k); - const_iterator find(const key_type& k) const; - size_type count(const key_type& k) const; - pair equal_range(const key_type& k); - pair equal_range(const key_type& k) const; - - size_type bucket_count() const noexcept; - size_type max_bucket_count() const noexcept; - - size_type bucket_size(size_type n) const; - size_type bucket(const key_type& k) const; - - local_iterator begin(size_type n); - local_iterator end(size_type n); - const_local_iterator begin(size_type n) const; - const_local_iterator end(size_type n) const; - const_local_iterator cbegin(size_type n) const; - const_local_iterator cend(size_type n) const; - - float load_factor() const noexcept; - float max_load_factor() const noexcept; - void max_load_factor(float z); - void rehash(size_type n); - void reserve(size_type n); -}; - -template , class Pred = equal_to, - class Allocator = allocator > > -class hash_map -{ -public: - // types - typedef Key key_type; - typedef T mapped_type; - typedef Hash hasher; - typedef Pred key_equal; - typedef Allocator allocator_type; - typedef pair value_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename allocator_traits::pointer pointer; - typedef typename allocator_traits::const_pointer const_pointer; - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::difference_type difference_type; - - typedef /unspecified/ iterator; - typedef /unspecified/ const_iterator; - typedef /unspecified/ local_iterator; - typedef /unspecified/ const_local_iterator; - - hash_map() - noexcept( - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value); - explicit hash_map(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - template - hash_map(InputIterator f, InputIterator l, - size_type n = 0, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - explicit hash_map(const allocator_type&); - hash_map(const hash_map&); - hash_map(const hash_map&, const Allocator&); - hash_map(hash_map&&) - noexcept( - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value); - hash_map(hash_map&&, const Allocator&); - hash_map(initializer_list, size_type n = 0, - const hasher& hf = hasher(), const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - ~hash_map(); - hash_map& operator=(const hash_map&); - hash_map& operator=(hash_map&&) - noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); - hash_map& operator=(initializer_list); - - allocator_type get_allocator() const noexcept; - - bool empty() const noexcept; - size_type size() const noexcept; - size_type max_size() const noexcept; - - iterator begin() noexcept; - iterator end() noexcept; - const_iterator begin() const noexcept; - const_iterator end() const noexcept; - const_iterator cbegin() const noexcept; - const_iterator cend() const noexcept; - - template - pair emplace(BOOST_FWD_REF(Args)... args); - template - iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args); - pair insert(const value_type& obj); - template - pair insert(P&& obj); - iterator insert(const_iterator hint, const value_type& obj); - template - iterator insert(const_iterator hint, P&& obj); - template - void insert(InputIterator first, InputIterator last); - void insert(initializer_list); - - iterator erase(const_iterator position); - size_type erase(const key_type& k); - iterator erase(const_iterator first, const_iterator last); - void clear() noexcept; - - void swap(hash_map&) - noexcept( - (!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value) && - __is_nothrow_swappable::value && - __is_nothrow_swappable::value); - - hasher hash_function() const; - key_equal key_eq() const; - - iterator find(const key_type& k); - const_iterator find(const key_type& k) const; - size_type count(const key_type& k) const; - pair equal_range(const key_type& k); - pair equal_range(const key_type& k) const; - - mapped_type& operator[](const key_type& k); - mapped_type& operator[](key_type&& k); - - mapped_type& at(const key_type& k); - const mapped_type& at(const key_type& k) const; - - size_type bucket_count() const noexcept; - size_type max_bucket_count() const noexcept; - - size_type bucket_size(size_type n) const; - size_type bucket(const key_type& k) const; - - local_iterator begin(size_type n); - local_iterator end(size_type n); - const_local_iterator begin(size_type n) const; - const_local_iterator end(size_type n) const; - const_local_iterator cbegin(size_type n) const; - const_local_iterator cend(size_type n) const; - - float load_factor() const noexcept; - float max_load_factor() const noexcept; - void max_load_factor(float z); - void rehash(size_type n); - void reserve(size_type n); -}; - -*/ - -template , class Pred = equal_to, - class Allocator = allocator > -class hash_table -{ -public: - // types - typedef Value key_type; - typedef key_type value_type; - typedef Hash hasher; - typedef Pred key_equal; - typedef Allocator allocator_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename allocator_traits::pointer pointer; - typedef typename allocator_traits::const_pointer const_pointer; - typedef typename allocator_traits::size_type size_type; - typedef typename allocator_traits::difference_type difference_type; - - typedef /unspecified/ iterator; - typedef /unspecified/ const_iterator; - typedef /unspecified/ local_iterator; - typedef /unspecified/ const_local_iterator; - - hash_set() - noexcept( - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value); - explicit hash_set(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - template - hash_set(InputIterator f, InputIterator l, - size_type n = 0, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - explicit hash_set(const allocator_type&); - hash_set(const hash_set&); - hash_set(const hash_set&, const Allocator&); - hash_set(hash_set&&) - noexcept( - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value); - hash_set(hash_set&&, const Allocator&); - hash_set(initializer_list, size_type n = 0, - const hasher& hf = hasher(), const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - ~hash_set(); - hash_set& operator=(const hash_set&); - hash_set& operator=(hash_set&&) - noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); - hash_set& operator=(initializer_list); - - allocator_type get_allocator() const noexcept; - - bool empty() const noexcept; - size_type size() const noexcept; - size_type max_size() const noexcept; - - iterator begin() noexcept; - iterator end() noexcept; - const_iterator begin() const noexcept; - const_iterator end() const noexcept; - const_iterator cbegin() const noexcept; - const_iterator cend() const noexcept; - - template - pair emplace(BOOST_FWD_REF(Args)... args); - template - iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args); - pair insert(const value_type& obj); - pair insert(value_type&& obj); - iterator insert(const_iterator hint, const value_type& obj); - iterator insert(const_iterator hint, value_type&& obj); - template - void insert(InputIterator first, InputIterator last); - void insert(initializer_list); - - iterator erase(const_iterator position); - size_type erase(const key_type& k); - iterator erase(const_iterator first, const_iterator last); - void clear() noexcept; - - void swap(hash_set&) - noexcept( - (!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable::value) && - __is_nothrow_swappable::value && - __is_nothrow_swappable::value); - - hasher hash_function() const; - key_equal key_eq() const; - - iterator find(const key_type& k); - const_iterator find(const key_type& k) const; - size_type count(const key_type& k) const; - pair equal_range(const key_type& k); - pair equal_range(const key_type& k) const; - - size_type bucket_count() const noexcept; - size_type max_bucket_count() const noexcept; - - size_type bucket_size(size_type n) const; - size_type bucket(const key_type& k) const; - - local_iterator begin(size_type n); - local_iterator end(size_type n); - const_local_iterator begin(size_type n) const; - const_local_iterator end(size_type n) const; - const_local_iterator cbegin(size_type n) const; - const_local_iterator cend(size_type n) const; - - float load_factor() const noexcept; - float max_load_factor() const noexcept; - void max_load_factor(float z); - void rehash(size_type n); - void reserve(size_type n); -}; diff --git a/include/boost/container/detail/mutex.hpp b/include/boost/container/detail/mutex.hpp index 82e8810..9743614 100644 --- a/include/boost/container/detail/mutex.hpp +++ b/include/boost/container/detail/mutex.hpp @@ -1,14 +1,9 @@ -// Copyright (C) 2000 Stephen Cleary -// -// 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 for updates, documentation, and revision history. - ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2007-2013. Distributed under the Boost +// (C) Copyright Stephen Cleary 2000 +// (C) Copyright Ion Gaztanaga 2015-2017. +// +// 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) // diff --git a/include/boost/container/new_allocator.hpp b/include/boost/container/new_allocator.hpp index 9304a9c..51065ef 100644 --- a/include/boost/container/new_allocator.hpp +++ b/include/boost/container/new_allocator.hpp @@ -140,9 +140,9 @@ class new_allocator //!Throws std::bad_alloc if there is no enough memory pointer allocate(size_type count) { - if(BOOST_UNLIKELY(count > this->max_size())) - throw_bad_alloc(); - return static_cast(::operator new(count*sizeof(T))); + if(BOOST_UNLIKELY(count > this->max_size())) + throw_bad_alloc(); + return static_cast(::operator new(count*sizeof(T))); } //!Deallocates previously allocated memory. diff --git a/include/boost/container/small_vector.hpp b/include/boost/container/small_vector.hpp index e23b54f..1444624 100644 --- a/include/boost/container/small_vector.hpp +++ b/include/boost/container/small_vector.hpp @@ -507,7 +507,7 @@ class small_vector : public small_vector_base public: BOOST_CONTAINER_FORCEINLINE small_vector() - BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value) + BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible::value) : base_type(initial_capacity_t(), internal_capacity()) {} diff --git a/proj/vc7ide/static_vector_test.vcproj b/proj/vc7ide/static_vector_test.vcproj index 7da628a..2c3dcc9 100644 --- a/proj/vc7ide/static_vector_test.vcproj +++ b/proj/vc7ide/static_vector_test.vcproj @@ -1,136 +1,135 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/map_test.cpp b/test/map_test.cpp index ae7abf0..121abb2 100644 --- a/test/map_test.cpp +++ b/test/map_test.cpp @@ -391,10 +391,10 @@ int main () //Test std::pair value type as tree has workarounds to make old std::pair //implementations movable that can break things { - boost::container::map s; - std::pair p; - s.insert(p); - s.emplace(p); + boost::container::map s; + std::pair p; + s.insert(p); + s.emplace(p); } //////////////////////////////////// diff --git a/test/scoped_allocator_adaptor_test.cpp b/test/scoped_allocator_adaptor_test.cpp index d21afa4..51d6ee1 100644 --- a/test/scoped_allocator_adaptor_test.cpp +++ b/test/scoped_allocator_adaptor_test.cpp @@ -1331,6 +1331,44 @@ int main() dummy.~MarkTypePair(); } #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE + + //Check construction with try_emplace_t 0/1 arguments for each pair + { + typedef ::allocator_argument_tester MarkType; + typedef pair MarkTypePair; + MarkTypePair dummy; + dummy.~MarkTypePair(); + s0i.construct(&dummy, try_emplace_t(), 5, 1); + BOOST_TEST(dummy.first.construction_type == NotUsesAllocator); + BOOST_TEST(dummy.second.construction_type == NotUsesAllocator); + BOOST_TEST(dummy.first.value == 5); + BOOST_TEST(dummy.second.value == 1); + dummy.~MarkTypePair(); + } + { + typedef ::allocator_argument_tester MarkType; + typedef pair MarkTypePair; + MarkTypePair dummy; + dummy.~MarkTypePair(); + s0i.construct(&dummy, try_emplace_t(), 6); + BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix); + BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix); + BOOST_TEST(dummy.first.value == 6); + BOOST_TEST(dummy.second.value == 0); + dummy.~MarkTypePair(); + } + { + typedef ::allocator_argument_tester MarkType; + typedef pair MarkTypePair; + MarkTypePair dummy; + dummy.~MarkTypePair(); + s0i.construct(&dummy, try_emplace_t(), 7, 2); + BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix); + BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix); + BOOST_TEST(dummy.first.value == 7); + BOOST_TEST(dummy.second.value == 2); + dummy.~MarkTypePair(); + } } } diff --git a/test/set_test.cpp b/test/set_test.cpp index 5caaa29..c2ce696 100644 --- a/test/set_test.cpp +++ b/test/set_test.cpp @@ -379,10 +379,10 @@ int main () //Test std::pair value type as tree has workarounds to make old std::pair //implementations movable that can break things { - boost::container::set > s; - std::pair p(0, 0); - s.insert(p); - s.emplace(p); + boost::container::set > s; + std::pair p(0, 0); + s.insert(p); + s.emplace(p); } test_merge_from_different_comparison(); diff --git a/test/static_vector_test.cpp b/test/static_vector_test.cpp index df03834..a80d0de 100644 --- a/test/static_vector_test.cpp +++ b/test/static_vector_test.cpp @@ -650,10 +650,13 @@ void test_sv_elem(T const& t) bool default_init_test()//Test for default initialization { - typedef static_vector di_vector_t; - const std::size_t Capacity = 100; + typedef static_vector di_vector_t; + + { + di_vector_t v(Capacity, default_init); + } { di_vector_t v; int *p = v.data(); @@ -662,7 +665,7 @@ bool default_init_test()//Test for default initialization *p = static_cast(i); } - //Destroy the vector, p stilll pointing to the storage + //Destroy the vector, p still pointing to the storage v.~di_vector_t(); di_vector_t &rv = *::new(&v)di_vector_t(Capacity, default_init);