diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-09-13 11:08:07 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-09-13 11:09:00 +0900 |
commit | b5c87084afaef42b2d058f68091be31988a6a874 (patch) | |
tree | adef9a65870a41181687e11d57fdf98e7629de3c /boost/container | |
parent | 34bd32e225e2a8a94104489b31c42e5801cc1f4a (diff) | |
download | boost-b5c87084afaef42b2d058f68091be31988a6a874.tar.gz boost-b5c87084afaef42b2d058f68091be31988a6a874.tar.bz2 boost-b5c87084afaef42b2d058f68091be31988a6a874.zip |
Imported Upstream version 1.64.0upstream/1.64.0
Change-Id: Id9212edd016dd55f21172c427aa7894d1d24148b
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/container')
-rw-r--r-- | boost/container/allocator_traits.hpp | 54 | ||||
-rw-r--r-- | boost/container/detail/advanced_insert_int.hpp | 4 | ||||
-rw-r--r-- | boost/container/detail/dispatch_uses_allocator.hpp | 56 | ||||
-rw-r--r-- | boost/container/detail/hash_table.hpp | 383 | ||||
-rw-r--r-- | boost/container/detail/mutex.hpp | 13 | ||||
-rw-r--r-- | boost/container/detail/workaround.hpp | 4 | ||||
-rw-r--r-- | boost/container/new_allocator.hpp | 6 | ||||
-rw-r--r-- | boost/container/node_handle.hpp | 5 | ||||
-rw-r--r-- | boost/container/small_vector.hpp | 2 | ||||
-rw-r--r-- | boost/container/string.hpp | 473 | ||||
-rw-r--r-- | boost/container/vector.hpp | 10 |
11 files changed, 507 insertions, 503 deletions
diff --git a/boost/container/allocator_traits.hpp b/boost/container/allocator_traits.hpp index e6a882e594..d6621f614a 100644 --- a/boost/container/allocator_traits.hpp +++ b/boost/container/allocator_traits.hpp @@ -289,18 +289,18 @@ struct allocator_traits //! <b>Returns</b>: <code>a.allocate(n)</code> //! - static pointer allocate(Allocator &a, size_type n) + BOOST_CONTAINER_FORCEINLINE static pointer allocate(Allocator &a, size_type n) { return a.allocate(n); } //! <b>Returns</b>: <code>a.deallocate(p, n)</code> //! //! <b>Throws</b>: 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); } //! <b>Effects</b>: calls <code>a.allocate(n, p)</code> if that call is well-formed; //! otherwise, invokes <code>a.allocate(n)</code> - 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 //! <b>Effects</b>: calls <code>a.destroy(p)</code> if that call is well-formed; //! otherwise, invokes <code>p->~T()</code>. template<class T> - 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 //! <b>Returns</b>: <code>a.max_size()</code> if that expression is well-formed; otherwise, //! <code>numeric_limits<size_type>::max()</code>. - 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<Allocator, size_type (Allocator::*)() const>::value; container_detail::bool_<value> flag; @@ -333,7 +333,7 @@ struct allocator_traits //! <b>Returns</b>: <code>a.select_on_container_copy_construction()</code> 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<Allocator BOOST_MOVE_I Allocator (Allocator::*)() const>::value BOOST_MOVE_I Allocator BOOST_MOVE_I const Allocator & >::type) @@ -349,7 +349,7 @@ struct allocator_traits //! <b>Effects</b>: calls <code>a.construct(p, std::forward<Args>(args)...)</code> if that call is well-formed; //! otherwise, invokes <code>::new (static_cast<void*>(p)) T(std::forward<Args>(args)...)</code> template <class T, class ...Args> - 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<Allocator> @@ -363,7 +363,7 @@ struct allocator_traits //! <b>Returns</b>: <code>a.storage_is_unpropagable(p)</code> if is_partially_propagable::value is true; otherwise, //! <code>false</code>. - 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_<is_partially_propagable::value> flag; return allocator_traits::priv_storage_is_unpropagable(flag, a, p); @@ -371,7 +371,7 @@ struct allocator_traits //! <b>Returns</b>: <code>true</code> if <code>is_always_equal::value == true</code>, otherwise, //! <code>a == b</code>. - 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_<is_always_equal::value> 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<class T> - 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<class T> - 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<class T, class ...Args> - 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>(args)...); } template<class T, class ...Args> - 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>(args)...); } #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) public: #define BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL(N) \ template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ - 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<Allocator> \ @@ -438,11 +438,11 @@ struct allocator_traits ///////////////////////////////// #define BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL(N) \ template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ - 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<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ - 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<class T> - 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/boost/container/detail/advanced_insert_int.hpp b/boost/container/detail/advanced_insert_int.hpp index 278cd1b3f1..1050857c46 100644 --- a/boost/container/detail/advanced_insert_int.hpp +++ b/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/boost/container/detail/dispatch_uses_allocator.hpp b/boost/container/detail/dispatch_uses_allocator.hpp index fdf203cef8..946fdf615b 100644 --- a/boost/container/detail/dispatch_uses_allocator.hpp +++ b/boost/container/detail/dispatch_uses_allocator.hpp @@ -287,7 +287,7 @@ template< typename ConstructAlloc, typename ArgAlloc, class Pair \ , template<class, class, class, class, class, class, class, class, class, class> 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<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<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,N),::boost::tuples::null_type)> p\ , BoostTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::boost::tuples::null_type)> 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 ...> 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<Args1...>& t1, Tuple<Args2...>& t2, index_tuple<Indexes1...>, index_tuple<Indexes2...>) { (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 ...> class Tuple, class... Args1, class... Args2> typename container_detail::enable_if< container_detail::is_pair<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<Args1...> t1, Tuple<Args2...> 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, class, class, class, class, class, class, class, class, class> 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<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<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,N),::std::tr1::_Nil)> p\ , StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::std::tr1::_Nil)> 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<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<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(BOOST_MOVE_ADD(_VARIADIC_MAX, 3),N),::std::_Nil) > p\ , StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(BOOST_MOVE_ADD(_VARIADIC_MAX, 3),M),::std::_Nil) > 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<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<KeyType>(k)); + BOOST_TRY{ + (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->second), ::boost::forward<Args>(args)...); + } + BOOST_CATCH(...) { + allocator_traits<ConstructAlloc>::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 <typename ConstructAlloc, typename ArgAlloc, class Pair, class KeyType BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ + inline typename container_detail::enable_if\ + < container_detail::is_pair<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<KeyType>(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<ConstructAlloc>::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/boost/container/detail/hash_table.hpp b/boost/container/detail/hash_table.hpp deleted file mode 100644 index 4bc5c901de..0000000000 --- a/boost/container/detail/hash_table.hpp +++ /dev/null @@ -1,383 +0,0 @@ -/* -template <class Value, unsigned int Options = 0, class Hash = hash<Value>, class Pred = equal_to<Value>, - class Allocator = allocator<Value> > -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<allocator_type>::pointer pointer; - typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; - typedef typename allocator_traits<allocator_type>::size_type size_type; - typedef typename allocator_traits<allocator_type>::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<hasher>::value && - is_nothrow_default_constructible<key_equal>::value && - is_nothrow_default_constructible<allocator_type>::value); - explicit hash_set(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - template <class InputIterator> - 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<hasher>::value && - is_nothrow_move_constructible<key_equal>::value && - is_nothrow_move_constructible<allocator_type>::value); - hash_set(hash_set&&, const Allocator&); - hash_set(initializer_list<value_type>, 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<allocator_type>::value && - is_nothrow_move_assignable<hasher>::value && - is_nothrow_move_assignable<key_equal>::value); - hash_set& operator=(initializer_list<value_type>); - - 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 <class... Args> - pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args); - template <class... Args> - iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args); - pair<iterator, bool> insert(const value_type& obj); - pair<iterator, bool> insert(value_type&& obj); - iterator insert(const_iterator hint, const value_type& obj); - iterator insert(const_iterator hint, value_type&& obj); - template <class InputIterator> - void insert(InputIterator first, InputIterator last); - void insert(initializer_list<value_type>); - - 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<allocator_type>::value) && - __is_nothrow_swappable<hasher>::value && - __is_nothrow_swappable<key_equal>::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<iterator, iterator> equal_range(const key_type& k); - pair<const_iterator, const_iterator> 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 Key, class T, unsigned int Options = 0, class Hash = hash<Key>, class Pred = equal_to<Key>, - class Allocator = allocator<pair<const Key, T> > > -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<const key_type, mapped_type> value_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename allocator_traits<allocator_type>::pointer pointer; - typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; - typedef typename allocator_traits<allocator_type>::size_type size_type; - typedef typename allocator_traits<allocator_type>::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<hasher>::value && - is_nothrow_default_constructible<key_equal>::value && - is_nothrow_default_constructible<allocator_type>::value); - explicit hash_map(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - template <class InputIterator> - 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<hasher>::value && - is_nothrow_move_constructible<key_equal>::value && - is_nothrow_move_constructible<allocator_type>::value); - hash_map(hash_map&&, const Allocator&); - hash_map(initializer_list<value_type>, 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<allocator_type>::value && - is_nothrow_move_assignable<hasher>::value && - is_nothrow_move_assignable<key_equal>::value); - hash_map& operator=(initializer_list<value_type>); - - 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 <class... Args> - pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args); - template <class... Args> - iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args); - pair<iterator, bool> insert(const value_type& obj); - template <class P> - pair<iterator, bool> insert(P&& obj); - iterator insert(const_iterator hint, const value_type& obj); - template <class P> - iterator insert(const_iterator hint, P&& obj); - template <class InputIterator> - void insert(InputIterator first, InputIterator last); - void insert(initializer_list<value_type>); - - 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<allocator_type>::value) && - __is_nothrow_swappable<hasher>::value && - __is_nothrow_swappable<key_equal>::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<iterator, iterator> equal_range(const key_type& k); - pair<const_iterator, const_iterator> 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 Key, class Value, class KeyOfValue, unsigned int Options = 0, class Hash = hash<Key>, class Pred = equal_to<Key>, - class Allocator = allocator<Value> > -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<allocator_type>::pointer pointer; - typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; - typedef typename allocator_traits<allocator_type>::size_type size_type; - typedef typename allocator_traits<allocator_type>::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<hasher>::value && - is_nothrow_default_constructible<key_equal>::value && - is_nothrow_default_constructible<allocator_type>::value); - explicit hash_set(size_type n, const hasher& hf = hasher(), - const key_equal& eql = key_equal(), - const allocator_type& a = allocator_type()); - template <class InputIterator> - 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<hasher>::value && - is_nothrow_move_constructible<key_equal>::value && - is_nothrow_move_constructible<allocator_type>::value); - hash_set(hash_set&&, const Allocator&); - hash_set(initializer_list<value_type>, 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<allocator_type>::value && - is_nothrow_move_assignable<hasher>::value && - is_nothrow_move_assignable<key_equal>::value); - hash_set& operator=(initializer_list<value_type>); - - 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 <class... Args> - pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args); - template <class... Args> - iterator emplace_hint(const_iterator position, BOOST_FWD_REF(Args)... args); - pair<iterator, bool> insert(const value_type& obj); - pair<iterator, bool> insert(value_type&& obj); - iterator insert(const_iterator hint, const value_type& obj); - iterator insert(const_iterator hint, value_type&& obj); - template <class InputIterator> - void insert(InputIterator first, InputIterator last); - void insert(initializer_list<value_type>); - - 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<allocator_type>::value) && - __is_nothrow_swappable<hasher>::value && - __is_nothrow_swappable<key_equal>::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<iterator, iterator> equal_range(const key_type& k); - pair<const_iterator, const_iterator> 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/boost/container/detail/mutex.hpp b/boost/container/detail/mutex.hpp index 82e8810d0a..9743614c23 100644 --- a/boost/container/detail/mutex.hpp +++ b/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/boost/container/detail/workaround.hpp b/boost/container/detail/workaround.hpp index ed57718ba9..816d3cc84d 100644 --- a/boost/container/detail/workaround.hpp +++ b/boost/container/detail/workaround.hpp @@ -49,6 +49,10 @@ #define BOOST_CONTAINER_FALLTHOUGH BOOST_FALLTHOUGH; #endif +#if defined(BOOST_MSVC) && (_MSC_VER < 1400) + #define BOOST_CONTAINER_TEMPLATED_CONVERSION_OPERATOR_BROKEN +#endif + #if !defined(BOOST_NO_CXX11_HDR_TUPLE) || (defined(BOOST_MSVC) && (BOOST_MSVC == 1700 || BOOST_MSVC == 1600)) #define BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE #endif diff --git a/boost/container/new_allocator.hpp b/boost/container/new_allocator.hpp index 9304a9cfa4..51065efa73 100644 --- a/boost/container/new_allocator.hpp +++ b/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<T*>(::operator new(count*sizeof(T))); + if(BOOST_UNLIKELY(count > this->max_size())) + throw_bad_alloc(); + return static_cast<T*>(::operator new(count*sizeof(T))); } //!Deallocates previously allocated memory. diff --git a/boost/container/node_handle.hpp b/boost/container/node_handle.hpp index 300b4713ad..c46313cc4f 100644 --- a/boost/container/node_handle.hpp +++ b/boost/container/node_handle.hpp @@ -131,6 +131,9 @@ class node_handle nallocator_type &node_alloc() { return *static_cast<nallocator_type*>(m_nalloc_storage.address()); } + const nallocator_type &node_alloc() const + { return *static_cast<const nallocator_type*>(m_nalloc_storage.address()); } + node_pointer release() { node_pointer p(m_ptr); @@ -323,7 +326,7 @@ class node_handle if(was_nh_non_null){ if(was_this_non_null){ - if(ator_traits::propagate_on_container_swap){ + if(ator_traits::propagate_on_container_swap::value){ ::boost::adl_move_swap(this->node_alloc(), nh.node_alloc()); } } diff --git a/boost/container/small_vector.hpp b/boost/container/small_vector.hpp index e23b54f8ac..14446247ac 100644 --- a/boost/container/small_vector.hpp +++ b/boost/container/small_vector.hpp @@ -507,7 +507,7 @@ class small_vector : public small_vector_base<T, Allocator> public: BOOST_CONTAINER_FORCEINLINE small_vector() - BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value) + BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value) : base_type(initial_capacity_t(), internal_capacity()) {} diff --git a/boost/container/string.hpp b/boost/container/string.hpp index 1e47abaaf0..7b780fd588 100644 --- a/boost/container/string.hpp +++ b/boost/container/string.hpp @@ -37,16 +37,19 @@ #include <boost/container/detail/next_capacity.hpp> #include <boost/container/detail/to_raw_pointer.hpp> #include <boost/container/detail/version_type.hpp> +#include <boost/container/detail/type_traits.hpp> +#include <boost/container/detail/minimal_char_traits_header.hpp> + +#include <boost/intrusive/pointer_traits.hpp> #include <boost/move/utility_core.hpp> #include <boost/move/adl_move_swap.hpp> +#include <boost/move/traits.hpp> + #include <boost/static_assert.hpp> -#include <boost/intrusive/pointer_traits.hpp> #include <boost/core/no_exceptions_support.hpp> -#include <boost/container/detail/minimal_char_traits_header.hpp> #include <boost/functional/hash.hpp> - #include <algorithm> #include <functional> //bind2nd, etc. #include <iosfwd> @@ -56,8 +59,12 @@ #include <locale> #include <cstddef> #include <climits> -#include <boost/container/detail/type_traits.hpp> -#include <boost/move/traits.hpp> + +//std +#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) +#include <initializer_list> //for std::initializer_list +#endif + namespace boost { namespace container { @@ -615,6 +622,17 @@ class basic_string this->assign(s.begin(), s.end()); } + //! <b>Effects</b>: Same as basic_string(sv.data(), sv.size(), a). + //! + //! <b>Throws</b>: If allocator_type's default constructor or allocation throws. + template<template <class, class> class BasicStringView> + explicit basic_string(BasicStringView<CharT, Traits> sv, const Allocator& a = Allocator()) + : base_t(allocator_traits_type::select_on_container_copy_construction(a)) + { + this->priv_terminate_string(); + this->assign(sv); + } + //! <b>Effects</b>: Move constructor. Moves s's resources to *this. //! //! <b>Throws</b>: Nothing. @@ -780,6 +798,17 @@ class basic_string this->assign(f, l); } + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + //! <b>Effects</b>: Same as basic_string(il.begin(), il.end(), a). + //! + basic_string(std::initializer_list<value_type> il, const allocator_type& a = allocator_type()) + : base_t(a) + { + this->priv_terminate_string(); + this->assign(il.begin(), il.end()); + } + #endif + //! <b>Effects</b>: Destroys the basic_string. All used memory is deallocated. //! //! <b>Throws</b>: Nothing. @@ -852,13 +881,30 @@ class basic_string } //! <b>Effects</b>: Assignment from a null-terminated c-string. + //! basic_string& operator=(const CharT* s) { return this->assign(s, s + Traits::length(s)); } - //! <b>Effects</b>: Assignment from character. + //! <b>Effects</b>: Returns *this = basic_string(1, c). + //! basic_string& operator=(CharT c) { return this->assign(static_cast<size_type>(1), c); } + //! <b>Effects</b>: Equivalent to return assign(sv). + //! + template<template <class, class> class BasicStringView> + basic_string& operator=(BasicStringView<CharT, Traits> sv) + { return this->assign(sv.data(), sv.size()); } + + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + //! <b>Effects</b>: Returns *this = basic_string(il); + //! + basic_string& operator=(std::initializer_list<CharT> il) + { + return this->assign(il.begin(), il.end()); + } + #endif + //! <b>Effects</b>: Returns a copy of the internal allocator. //! //! <b>Throws</b>: If allocator's copy constructor throws. @@ -1256,6 +1302,14 @@ class basic_string basic_string& operator+=(const basic_string& s) { return this->append(s); } + //! <b>Effects</b>: Same as `return append(sv)`. + //! + template<template<class, class> class BasicStringView> + basic_string& operator+=(BasicStringView<CharT, Traits> sv) + { + return this->append(sv); + } + //! <b>Effects</b>: Calls append(s). //! //! <b>Returns</b>: *this @@ -1268,12 +1322,27 @@ class basic_string basic_string& operator+=(CharT c) { this->push_back(c); return *this; } + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + //! <b>Effects</b>: Returns append(il) + //! + basic_string& operator+=(std::initializer_list<CharT> il) + { + return this->append(il); + } + #endif + //! <b>Effects</b>: Calls append(str.data(), str.size()). //! //! <b>Returns</b>: *this basic_string& append(const basic_string& s) { return this->append(s.begin(), s.end()); } + //! <b>Effects</b>: Same as return append(sv.data(), sv.size()). + //! + template<template<class, class> class BasicStringView> + basic_string& append(BasicStringView<CharT, Traits> sv) + { return this->append(sv.data(), sv.size()); } + //! <b>Requires</b>: pos <= str.size() //! //! <b>Effects</b>: Determines the effective length rlen of the string to append @@ -1282,7 +1351,7 @@ class basic_string //! <b>Throws</b>: If memory allocation throws and out_of_range if pos > str.size() //! //! <b>Returns</b>: *this - basic_string& append(const basic_string& s, size_type pos, size_type n) + basic_string& append(const basic_string& s, size_type pos, size_type n = npos) { if (pos > s.size()) throw_out_of_range("basic_string::append out of range position"); @@ -1326,7 +1395,17 @@ class basic_string basic_string& append(InputIter first, InputIter last) { this->insert(this->end(), first, last); return *this; } + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + //! <b>Effects</b>: Returns append(il.begin(), il.size()). + //! + basic_string& append(std::initializer_list<CharT> il) + { + return this->append(il.begin(), il.size()); + } + #endif + //! <b>Effects</b>: Equivalent to append(static_cast<size_type>(1), c). + //! void push_back(CharT c) { const size_type old_size = this->priv_size(); @@ -1348,6 +1427,13 @@ class basic_string basic_string& assign(const basic_string& s) { return this->operator=(s); } + //! <b>Effects</b>: Equivalent to return assign(sv.data(), sv.size()). + //! + //! <b>Returns</b>: *this + template<template <class, class> class BasicStringView> + basic_string& assign(BasicStringView<CharT, Traits> sv) + { return this->operator=(sv); } + //! <b>Effects</b>: The function replaces the string controlled by *this //! with a string of length str.size() whose elements are a copy of the string //! controlled by str. Leaves str in a valid but unspecified state. @@ -1440,6 +1526,15 @@ class basic_string return *this; } + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + //! <b>Effects</b>: Returns assign(il.begin(), il.size()). + //! + basic_string& assign(std::initializer_list<CharT> il) + { + return this->assign(il.begin(), il.size()); + } + #endif + //! <b>Requires</b>: pos <= size(). //! //! <b>Effects</b>: Calls insert(pos, str.data(), str.size()). @@ -1466,7 +1561,7 @@ class basic_string //! <b>Throws</b>: If memory allocation throws or out_of_range if pos1 > size() or pos2 > str.size(). //! //! <b>Returns</b>: *this - basic_string& insert(size_type pos1, const basic_string& s, size_type pos2, size_type n) + basic_string& insert(size_type pos1, const basic_string& s, size_type pos2, size_type n = npos) { const size_type sz = this->size(); const size_type str_size = s.size(); @@ -1537,6 +1632,12 @@ class basic_string return *this; } + //! <b>Effects</b>: Same as `return insert(pos, sv.data(), sv.size())`. + //! + template<template<class, class> class BasicStringView> + basic_string& insert(size_type pos, BasicStringView<CharT, Traits> sv) + { return this->insert(pos, sv.data(), sv.size()); } + //! <b>Requires</b>: p is a valid iterator on *this. //! //! <b>Effects</b>: inserts a copy of c before the character referred to by p. @@ -1549,7 +1650,6 @@ class basic_string return this->priv_addr() + new_offset; } - //! <b>Requires</b>: p is a valid iterator on *this. //! //! <b>Effects</b>: Inserts n copies of c before the character referred to by p. @@ -1695,6 +1795,17 @@ class basic_string } #endif + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + //! <b>Effects</b>: As if by insert(p, il.begin(), il.end()). + //! + //! <b>Returns</b>: An iterator which refers to the copy of the first inserted + //! character, or p if i1 is empty. + iterator insert(const_iterator p, std::initializer_list<CharT> il) + { + return this->insert(p, il.begin(), il.end()); + } + #endif + //! <b>Effects</b>: Removes the last element from the container. //! //! <b>Throws</b>: Nothing. @@ -1801,6 +1912,14 @@ class basic_string , str.begin(), str.end()); } + //! <b>Effects</b>: Calls `return replace(pos1, n1, sv.data(), sv.size());`. + //! + template<template<class, class> class BasicStringView> + basic_string& replace(size_type pos1, size_type n1, BasicStringView<CharT, Traits> sv) + { + return this->replace(pos1, n1, sv.data(), sv.size()); + } + //! <b>Requires</b>: pos1 <= size() and pos2 <= str.size(). //! //! <b>Effects</b>: Determines the effective length rlen of the string to be @@ -1811,18 +1930,26 @@ class basic_string //! //! <b>Returns</b>: *this basic_string& replace(size_type pos1, size_type n1, - const basic_string& str, size_type pos2, size_type n2) + const basic_string& str, size_type pos2, size_type n2 = npos) { - if (pos1 > this->size() || pos2 > str.size()) + if (pos2 > str.size()) throw_out_of_range("basic_string::replace out of range position"); - const size_type len1 = container_detail::min_value(n1, this->size() - pos1); - const size_type len2 = container_detail::min_value(n2, str.size() - pos2); - if (this->size() - len1 >= this->max_size() - len2) - throw_length_error("basic_string::replace max_size() exceeded"); - const pointer addr = this->priv_addr(); - const pointer straddr = str.priv_addr(); - return this->replace(addr + pos1, addr + pos1 + len1, - straddr + pos2, straddr + pos2 + len2); + return this->replace(pos1, n1, str.data()+pos2, container_detail::min_value(n2, str.size() - pos2)); + } + + //! <b>Throws</b>: out_of_range if pos1 > size() or pos2 > sv.size(). + //! + //! <b>Effects</b>: Determines the effective length rlen of the string to be inserted as the + //! smaller of n2 and sv.size() - pos2 and calls `replace(pos1, n1, sv.data() + pos2, rlen)`. + //! + //! <b>Returns</b>: *this. + template<template<class, class> class BasicStringView> + basic_string& replace(size_type pos1, size_type n1, BasicStringView<CharT, Traits> sv, + size_type pos2, size_type n2 = npos) + { + if (pos2 > sv.size()) + throw_out_of_range("basic_string::replace out of range position"); + return this->replace(pos1, n1, sv.data()+pos2, container_detail::min_value(n2, sv.size() - pos2)); } //! <b>Requires</b>: pos1 <= size() and s points to an array of at least n2 elements of CharT. @@ -1836,7 +1963,7 @@ class basic_string //! the original string controlled by *this beginning at position pos + xlen. //! //! <b>Throws</b>: if memory allocation throws, out_of_range if pos1 > size() or length_error - //! if the length of the resulting string would exceed max_size() + //! if the length of the resulting string would exceed max_size() //! //! <b>Returns</b>: *this basic_string& replace(size_type pos1, size_type n1, const CharT* s, size_type n2) @@ -1844,10 +1971,11 @@ class basic_string if (pos1 > this->size()) throw_out_of_range("basic_string::replace out of range position"); const size_type len = container_detail::min_value(n1, this->size() - pos1); - if (n2 > this->max_size() || size() - len >= this->max_size() - n2) + const size_type max_size = this->max_size(); + if (n2 > max_size || (this->size() - len) >= (max_size - n2)) throw_length_error("basic_string::replace max_size() exceeded"); - const pointer addr = this->priv_addr(); - return this->replace(addr + pos1, addr + pos1 + len, s, s + n2); + const pointer addr = this->priv_addr() + pos1; + return this->replace(addr, addr + len, s, s + n2); } //! <b>Requires</b>: pos1 <= size() and s points to an array of at least n2 elements of CharT. @@ -1866,15 +1994,7 @@ class basic_string //! <b>Returns</b>: *this basic_string& replace(size_type pos, size_type n1, const CharT* s) { - if (pos > this->size()) - throw_out_of_range("basic_string::replace out of range position"); - const size_type len = container_detail::min_value(n1, this->size() - pos); - const size_type n2 = Traits::length(s); - if (n2 > this->max_size() || this->size() - len >= this->max_size() - n2) - throw_length_error("basic_string::replace max_size() exceeded"); - const pointer addr = this->priv_addr(); - return this->replace(addr + pos, addr + pos + len, - s, s + Traits::length(s)); + return this->replace(pos, n1, s, Traits::length(s)); } //! <b>Requires</b>: pos1 <= size(). @@ -1904,7 +2024,7 @@ class basic_string //! //! <b>Returns</b>: *this basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str) - { return this->replace(i1, i2, str.begin(), str.end()); } + { return this->replace(i1, i2, str.data(), str.data()+str.size()); } //! <b>Requires</b>: [begin(),i1) and [i1,i2) are valid ranges and //! s points to an array of at least n elements @@ -2004,6 +2124,32 @@ class basic_string } #endif + //! <b>Requires</b>: [begin(), i1) and [i1, i2) are valid ranges. + //! + //! <b>Effects</b>: Calls `replace(i1 - begin(), i2 - i1, sv).`. + //! + //! <bReturns</b>: *this. + template<template <class, class> class BasicStringView> + basic_string& replace(const_iterator i1, const_iterator i2, BasicStringView<CharT, Traits> sv) + { + return this->replace( static_cast<size_type>(i1 - this->cbegin()) + , static_cast<size_type>(i2 - i1), sv); + } + + #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) + //! <b>Requires</b>: [begin(), i1) and [i1, i2) are valid ranges. + //! + //! <b>Effects</b>: Calls replace(i1 - begin(), i2 - i1, il.begin(), il.size()). + //! + //! <bReturns</b>: *this. + basic_string& replace(const_iterator i1, const_iterator i2, std::initializer_list<CharT> il) + { + return this->replace( static_cast<size_type>(i1 - this->cbegin()) + , static_cast<size_type>(i2 - i1) + , il.begin(), il.size()); + } + #endif + //! <b>Requires</b>: pos <= size() //! //! <b>Effects</b>: Determines the effective length rlen of the string to copy as the @@ -2059,6 +2205,31 @@ class basic_string const CharT* data() const BOOST_NOEXCEPT_OR_NOTHROW { return container_detail::to_raw_pointer(this->priv_addr()); } + //! <b>Returns</b>: A pointer p such that p + i == &operator[](i) for each i in [0,size()]. + //! + //! <b>Complexity</b>: constant time. + CharT* data() BOOST_NOEXCEPT_OR_NOTHROW + { return container_detail::to_raw_pointer(this->priv_addr()); } + + #ifndef BOOST_CONTAINER_TEMPLATED_CONVERSION_OPERATOR_BROKEN + //! <b>Returns</b>: a string_view to the characters in the string. + //! + //! <b>Complexity</b>: constant time. + template<template <class, class> class BasicStringView> + operator BasicStringView<CharT, Traits>() const BOOST_NOEXCEPT_OR_NOTHROW + { return this->to_view< BasicStringView<CharT, Traits> >(); } + #endif + + //! <b>Returns</b>: a string_view to the characters in the string. + //! + //! <b>Complexity</b>: constant time. + //! + //! <b>Note</b>: This function is available to write portable code for compilers + //! that don't support templated conversion operators. + template<class BasicStringView> + BasicStringView to_view() const BOOST_NOEXCEPT_OR_NOTHROW + { return BasicStringView(this->data(), this->size()); } + ////////////////////////////////////////////// // // string operations @@ -2066,7 +2237,8 @@ class basic_string ////////////////////////////////////////////// //! <b>Effects</b>: Determines the lowest position xpos, if possible, such that both - //! of the following conditions obtain: 19 pos <= xpos and xpos + str.size() <= size(); + //! of the following conditions hold: + //! 1) pos <= xpos and xpos + str.size() <= size(); //! 2) traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled by str. //! //! <b>Throws</b>: Nothing @@ -2075,6 +2247,18 @@ class basic_string size_type find(const basic_string& s, size_type pos = 0) const { return find(s.c_str(), pos, s.size()); } + //! <b>Effects</b>: Determines the lowest position xpos, if possible, such that both + //! of the following conditions hold: + //! 1) pos <= xpos and xpos + sv.size() <= size(); + //! 2) traits::eq(at(xpos+I), sv.at(I)) for all elements I of the string controlled by sv. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos. + template<template <class, class> class BasicStringView> + size_type find(BasicStringView<CharT, Traits> sv, size_type pos = 0) const + { return find(sv.data(), pos, sv.size()); } + //! <b>Requires</b>: s points to an array of at least n elements of CharT. //! //! <b>Throws</b>: Nothing @@ -2132,6 +2316,18 @@ class basic_string size_type rfind(const basic_string& str, size_type pos = npos) const { return rfind(str.c_str(), pos, str.size()); } + //! <b>Effects</b>: Determines the highest position xpos, if possible, such + //! that both of the following conditions obtain: + //! a) xpos <= pos and xpos + sv.size() <= size(); + //! b) traits::eq(at(xpos+I), sv.at(I)) for all elements I of the string controlled by sv. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos. + template<template <class, class> class BasicStringView> + size_type rfind(BasicStringView<CharT, Traits> sv, size_type pos = npos) const + { return rfind(sv.data(), pos, sv.size()); } + //! <b>Requires</b>: s points to an array of at least n elements of CharT. //! //! <b>Throws</b>: Nothing @@ -2188,8 +2384,19 @@ class basic_string //! <b>Throws</b>: Nothing //! //! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos. - size_type find_first_of(const basic_string& s, size_type pos = 0) const - { return find_first_of(s.c_str(), pos, s.size()); } + size_type find_first_of(const basic_string& str, size_type pos = 0) const + { return find_first_of(str.c_str(), pos, str.size()); } + + //! <b>Effects</b>: Determines the lowest position xpos, if possible, such that both of the + //! following conditions obtain: a) pos <= xpos and xpos < size(); + //! b) traits::eq(at(xpos), sv.at(I)) for some element I of the string controlled by sv. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos. + template<template <class, class> class BasicStringView> + size_type find_first_of(BasicStringView<CharT, Traits> sv, size_type pos = 0) const + { return find_first_of(sv.data(), pos, sv.size()); } //! <b>Requires</b>: s points to an array of at least n elements of CharT. //! @@ -2236,6 +2443,17 @@ class basic_string size_type find_last_of(const basic_string& str, size_type pos = npos) const { return find_last_of(str.c_str(), pos, str.size()); } + //! <b>Effects</b>: Determines the highest position xpos, if possible, such that both of + //! the following conditions obtain: a) xpos <= pos and xpos < size(); b) + //! traits::eq(at(xpos), str.at(I)) for some element I of the string controlled by str. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos. + template<template <class, class> class BasicStringView> + size_type find_last_of(BasicStringView<CharT, Traits> sv, size_type pos = npos) const + { return find_last_of(sv.data(), pos, sv.size()); } + //! <b>Requires</b>: s points to an array of at least n elements of CharT. //! //! <b>Throws</b>: Nothing @@ -2282,6 +2500,18 @@ class basic_string size_type find_first_not_of(const basic_string& str, size_type pos = 0) const { return find_first_not_of(str.c_str(), pos, str.size()); } + //! <b>Effects</b>: Determines the lowest position xpos, if possible, such that + //! both of the following conditions obtain: + //! a) pos <= xpos and xpos < size(); b) traits::eq(at(xpos), sv.at(I)) for no + //! element I of the string controlled by sv. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos. + template<template <class, class> class BasicStringView> + size_type find_first_not_of(BasicStringView<CharT, Traits> sv, size_type pos = 0) const + { return find_first_not_of(sv.data(), pos, sv.size()); } + //! <b>Requires</b>: s points to an array of at least traits::length(s) + 1 elements of CharT. //! //! <b>Throws</b>: Nothing @@ -2335,6 +2565,17 @@ class basic_string size_type find_last_not_of(const basic_string& str, size_type pos = npos) const { return find_last_not_of(str.c_str(), pos, str.size()); } + //! <b>Effects</b>: Determines the highest position xpos, if possible, such that + //! both of the following conditions obtain: a) xpos <= pos and xpos < size(); + //! b) traits::eq(at(xpos), sv.at(I)) for no element I of the string controlled by sv. + //! + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: xpos if the function can determine such a value for xpos. Otherwise, returns npos. + template<template <class, class> class BasicStringView> + size_type find_last_not_of(BasicStringView<CharT, Traits> sv, size_type pos = npos) const + { return find_last_not_of(sv.data(), pos, sv.size()); } + //! <b>Requires</b>: s points to an array of at least n elements of CharT. //! //! <b>Throws</b>: Nothing @@ -2398,7 +2639,7 @@ class basic_string addr + pos + container_detail::min_value(n, size() - pos), this->alloc()); } - //! <b>Effects</b>: Determines the effective length rlen of the string to copy as + //! <b>Effects</b>: Determines the effective length rlen of the string to compare as //! the smaller of size() and str.size(). The function then compares the two strings by //! calling traits::compare(data(), str.data(), rlen). //! @@ -2414,10 +2655,21 @@ class basic_string return s_compare(addr, addr + this->priv_size(), str_addr, str_addr + str.priv_size()); } + //! <b>Throws</b>: Nothing + //! + //! <b>Returns</b>: compare(basic_string(sv)). + template<template <class, class> class BasicStringView> + int compare(BasicStringView<CharT,Traits> sv) const + { + const pointer addr = this->priv_addr(); + return s_compare(addr, addr + this->priv_size(), sv.data(), sv.data() + sv.size()); + } + //! <b>Requires</b>: pos1 <= size() //! - //! <b>Effects</b>: Determines the effective length rlen of the string to copy as - //! the smaller of + //! <b>Effects</b>: Determines the effective length rlen of the string to compare as + //! the smaller of (this->size() - pos1), n1 and str.size(). The function then compares the two strings by + //! calling traits::compare(data()+pos1, str.data(), rlen). //! //! <b>Throws</b>: out_of_range if pos1 > size() //! @@ -2433,6 +2685,22 @@ class basic_string str_addr, str_addr + str.priv_size()); } + //! <b>Requires</b>: pos1 <= size() + //! + //! <b>Throws</b>: out_of_range if pos1 > size() + //! + //! <b>Returns</b>:basic_string(*this,pos1,n1).compare(sv). + template<template <class, class> class BasicStringView> + int compare(size_type pos1, size_type n1, BasicStringView<CharT,Traits> sv) const + { + if (pos1 > this->size()) + throw_out_of_range("basic_string::compare out of range position"); + const pointer addr = this->priv_addr() + pos1; + const CharT* str_addr = sv.data(); + return s_compare(addr, addr + container_detail::min_value(n1, this->size() - pos1), + str_addr, str_addr + sv.size()); + } + //! <b>Requires</b>: pos1 <= size() and pos2 <= str.size() //! //! <b>Effects</b>: Determines the effective length rlen of the string to copy as @@ -2441,16 +2709,33 @@ class basic_string //! <b>Throws</b>: out_of_range if pos1 > size() or pos2 > str.size() //! //! <b>Returns</b>: basic_string(*this, pos1, n1).compare(basic_string(str, pos2, n2)). - int compare(size_type pos1, size_type n1, const basic_string& str, size_type pos2, size_type n2) const + int compare(size_type pos1, size_type n1, const basic_string& str, size_type pos2, size_type n2 = npos) const { if (pos1 > this->size() || pos2 > str.size()) throw_out_of_range("basic_string::compare out of range position"); - const pointer addr = this->priv_addr(); - const pointer str_addr = str.priv_addr(); - return s_compare(addr + pos1, - addr + pos1 + container_detail::min_value(n1, this->size() - pos1), - str_addr + pos2, - str_addr + pos2 + container_detail::min_value(n2, str.size() - pos2)); + const pointer addr = this->priv_addr() + pos1; + const pointer str_addr = str.priv_addr() + pos2; + return s_compare(addr, addr + container_detail::min_value(n1, this->size() - pos1), + str_addr, str_addr + container_detail::min_value(n2, str.size() - pos2)); + } + + //! <b>Requires</b>: pos1 <= size() and pos2 <= str.size() + //! + //! <b>Effects</b>: Determines the effective length rlen of the string to copy as + //! the smaller of + //! + //! <b>Throws</b>: out_of_range if pos1 > size() or pos2 > sv.size() + //! + //! <b>Returns</b>: basic_string(*this, pos1, n1).compare(BasicStringView<CharT, Traits>(sv, pos2, n2)). + template<template <class, class> class BasicStringView> + int compare(size_type pos1, size_type n1, BasicStringView<CharT,Traits> sv, size_type pos2, size_type n2) const + { + if (pos1 > this->size() || pos2 > sv.size()) + throw_out_of_range("basic_string::compare out of range position"); + const pointer addr = this->priv_addr() + pos1; + const CharT * str_addr = sv.data() + pos2; + return s_compare(addr, addr + container_detail::min_value(n1, this->size() - pos1), + str_addr, str_addr + container_detail::min_value(n2, sv.size() - pos2)); } //! <b>Throws</b>: Nothing @@ -2462,7 +2747,6 @@ class basic_string return s_compare(addr, addr + this->priv_size(), s, s + Traits::length(s)); } - //! <b>Requires</b>: pos1 > size() and s points to an array of at least n2 elements of CharT. //! //! <b>Throws</b>: out_of_range if pos1 > size() @@ -2515,8 +2799,8 @@ class basic_string } } - static int s_compare(const_pointer f1, const_pointer l1, - const_pointer f2, const_pointer l2) + template<class It1, class It2> + static int s_compare(It1 f1, It1 l1, It2 f2, It2 l2) { const difference_type n1 = l1 - f1; const difference_type n2 = l2 - f2; @@ -2753,8 +3037,7 @@ template <class CharT, class Traits, class Allocator> inline template <class CharT, class Traits, class Allocator> inline bool -operator==(const basic_string<CharT,Traits,Allocator>& x, - const basic_string<CharT,Traits,Allocator>& y) +operator==(const basic_string<CharT,Traits,Allocator>& x, const basic_string<CharT,Traits,Allocator>& y) { return x.size() == y.size() && Traits::compare(x.data(), y.data(), x.size()) == 0; @@ -2776,10 +3059,25 @@ operator==(const basic_string<CharT,Traits,Allocator>& x, const CharT* s) return x.size() == n && Traits::compare(x.data(), s, n) == 0; } +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator==( BasicStringView<CharT,Traits> x, const basic_string<CharT,Traits,Allocator>& y) +{ + return x.size() == y.size() && + Traits::compare(x.data(), y.data(), x.size()) == 0; +} + +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator==( const basic_string<CharT,Traits,Allocator>& x, BasicStringView<CharT,Traits> y) +{ + return x.size() == y.size() && + Traits::compare(x.data(), y.data(), x.size()) == 0; +} + template <class CharT, class Traits, class Allocator> inline bool -operator!=(const basic_string<CharT,Traits,Allocator>& x, - const basic_string<CharT,Traits,Allocator>& y) +operator!=(const basic_string<CharT,Traits,Allocator>& x, const basic_string<CharT,Traits,Allocator>& y) { return !(x == y); } template <class CharT, class Traits, class Allocator> @@ -2793,15 +3091,22 @@ operator!=(const basic_string<CharT,Traits,Allocator>& x, const CharT* s) { return !(x == s); } -// Operator< (and also >, <=, and >=). +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator!=( BasicStringView<CharT,Traits> x, const basic_string<CharT,Traits,Allocator>& y) + { return !(x == y); } + +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator!=( const basic_string<CharT,Traits,Allocator>& x, BasicStringView<CharT,Traits> y) + { return !(x == y); } +// Operator< (and also >, <=, and >=). template <class CharT, class Traits, class Allocator> inline bool operator<(const basic_string<CharT,Traits,Allocator>& x, const basic_string<CharT,Traits,Allocator>& y) { return x.compare(y) < 0; -// return basic_string<CharT,Traits,Allocator> -// ::s_compare(x.begin(), x.end(), y.begin(), y.end()) < 0; } template <class CharT, class Traits, class Allocator> @@ -2809,26 +3114,28 @@ inline bool operator<(const CharT* s, const basic_string<CharT,Traits,Allocator>& y) { return y.compare(s) > 0; -// basic_string<CharT,Traits,Allocator>::size_type n = Traits::length(s); -// return basic_string<CharT,Traits,Allocator> -// ::s_compare(s, s + n, y.begin(), y.end()) < 0; } template <class CharT, class Traits, class Allocator> inline bool -operator<(const basic_string<CharT,Traits,Allocator>& x, - const CharT* s) +operator<(const basic_string<CharT,Traits,Allocator>& x, const CharT* s) { return x.compare(s) < 0; -// basic_string<CharT,Traits,Allocator>::size_type n = Traits::length(s); -// return basic_string<CharT,Traits,Allocator> -// ::s_compare(x.begin(), x.end(), s, s + n) < 0; } +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator<( BasicStringView<CharT,Traits> x, const basic_string<CharT,Traits,Allocator>& y) + { return y.compare(x) > 0; } + +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator<( const basic_string<CharT,Traits,Allocator>& x, BasicStringView<CharT,Traits> y) + { return x.compare(y) < 0; } + template <class CharT, class Traits, class Allocator> inline bool -operator>(const basic_string<CharT,Traits,Allocator>& x, - const basic_string<CharT,Traits,Allocator>& y) { +operator>(const basic_string<CharT,Traits,Allocator>& x, const basic_string<CharT,Traits,Allocator>& y) { return y < x; } @@ -2845,10 +3152,19 @@ operator>(const basic_string<CharT,Traits,Allocator>& x, const CharT* s) return s < x; } +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator>( BasicStringView<CharT,Traits> x, const basic_string<CharT,Traits,Allocator>& y) + { return y < x; } + +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator>( const basic_string<CharT,Traits,Allocator>& x, BasicStringView<CharT,Traits> y) + { return y < x; } + template <class CharT, class Traits, class Allocator> inline bool -operator<=(const basic_string<CharT,Traits,Allocator>& x, - const basic_string<CharT,Traits,Allocator>& y) +operator<=(const basic_string<CharT,Traits,Allocator>& x, const basic_string<CharT,Traits,Allocator>& y) { return !(y < x); } @@ -2863,6 +3179,17 @@ inline bool operator<=(const basic_string<CharT,Traits,Allocator>& x, const CharT* s) { return !(s < x); } + +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator<=( BasicStringView<CharT,Traits> x, const basic_string<CharT,Traits,Allocator>& y) + { return !(y < x); } + +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator<=( const basic_string<CharT,Traits,Allocator>& x, BasicStringView<CharT,Traits> y) + { return !(y < x); } + template <class CharT, class Traits, class Allocator> inline bool operator>=(const basic_string<CharT,Traits,Allocator>& x, @@ -2879,6 +3206,16 @@ inline bool operator>=(const basic_string<CharT,Traits,Allocator>& x, const CharT* s) { return !(x < s); } +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator>=( BasicStringView<CharT,Traits> x, const basic_string<CharT,Traits,Allocator>& y) + { return !(x < y); } + +template <class CharT, class Traits, class Allocator, template <class, class> class BasicStringView> +inline bool +operator>=( const basic_string<CharT,Traits,Allocator>& x, BasicStringView<CharT,Traits> y) + { return !(x < y); } + // Swap. template <class CharT, class Traits, class Allocator> inline void swap(basic_string<CharT,Traits,Allocator>& x, basic_string<CharT,Traits,Allocator>& y) diff --git a/boost/container/vector.hpp b/boost/container/vector.hpp index 5d7d765e3d..336d616007 100644 --- a/boost/container/vector.hpp +++ b/boost/container/vector.hpp @@ -1735,9 +1735,10 @@ class vector { if (BOOST_LIKELY(this->room_enough())){ //There is more memory, just construct a new object at the end - allocator_traits_type::construct(this->m_holder.alloc(), this->priv_raw_end(), ::boost::forward<Args>(args)...); + T* const p = this->priv_raw_end(); + allocator_traits_type::construct(this->m_holder.alloc(), p, ::boost::forward<Args>(args)...); ++this->m_holder.m_size; - return *this->priv_raw_end(); + return *p; } else{ typedef container_detail::insert_emplace_proxy<Allocator, T*, Args...> type; @@ -1793,10 +1794,11 @@ class vector BOOST_CONTAINER_FORCEINLINE reference emplace_back(BOOST_MOVE_UREF##N)\ {\ if (BOOST_LIKELY(this->room_enough())){\ + T* const p = this->priv_raw_end();\ allocator_traits_type::construct (this->m_holder.alloc()\ , this->priv_raw_end() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ ++this->m_holder.m_size;\ - return *this->priv_raw_end();\ + return *p;\ }\ else{\ typedef container_detail::insert_emplace_proxy_arg##N<Allocator, T* BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\ @@ -2255,7 +2257,7 @@ class vector boost::uintptr_t const capaddr = boost::uintptr_t(this->priv_raw_begin() + c); boost::uintptr_t const aligned_addr = (addr + szt_align_mask) & ~szt_align_mask; indexes = reinterpret_cast<size_type *>(aligned_addr); - std::size_t index_capacity = (aligned_addr >= capaddr) ? 0u : (capaddr - addr)/sizeof(size_type); + std::size_t index_capacity = (aligned_addr >= capaddr) ? 0u : (capaddr - aligned_addr)/sizeof(size_type); //Capacity is constant, we're not going to change it if(index_capacity < PosCount){ |