llvm-project/libcxx/test/std/containers/sequences/vector/vector.cons
Eric Fiselier 69a4f66114 [libc++] Fix stack_allocator
Summary:
To quote STL the problems with stack allocator are"

>"stack_allocator<T, N> is seriously nonconformant to N4582 17.6.3.5 [allocator.requirements].
> First, it lacks a rebinding constructor. (The nested "struct rebind" isn't sufficient.)
> Second, it lacks templated equality/inequality.
> Third, it completely ignores alignment.
> Finally, and most severely, the Standard forbids its existence. Allocators are forbidden from returning memory "inside themselves". This requirement is implied by the Standard's requirements for rebinding and equality. It's permitted to return memory from a separate buffer object on the stack, though."

This patch attempts to address all of those issues.

First, instead of storing the buffer inside the allocator I've change `stack_allocator` to accept the buffer as an argument.

Second, in order to fix rebinding I changed the parameter list from `<class T, size_t NumElements>` to `<class T, size_t NumBytes>`. This allows allocator rebinding
between types that have different sizes. 

Third, I added copy and rebinding constructors and assignment operators.

And finally I fixed the allocation logic to always return properly aligned storage.



Reviewers: mclow.lists, howard.hinnant, STL_MSFT

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D25154

llvm-svn: 283631
2016-10-08 00:56:22 +00:00
..
assign_copy.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
assign_initializer_list.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
assign_move.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
assign_size_value.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
construct_default.pass.cpp [libc++] Fix stack_allocator 2016-10-08 00:56:22 +00:00
construct_iter_iter.pass.cpp [libc++] Fix stack_allocator 2016-10-08 00:56:22 +00:00
construct_iter_iter_alloc.pass.cpp [libc++] Fix stack_allocator 2016-10-08 00:56:22 +00:00
construct_size.pass.cpp Guard libc++ specific c.__invariants() tests in LIBCPP_ASSERT macros 2016-04-28 22:28:23 +00:00
construct_size_value.pass.cpp [libc++] Fix stack_allocator 2016-10-08 00:56:22 +00:00
construct_size_value_alloc.pass.cpp Guard libc++ specific c.__invariants() tests in LIBCPP_ASSERT macros 2016-04-28 22:28:23 +00:00
copy.pass.cpp Remove trailing whitespace in test suite. Approved by Marshall Clow. 2016-06-01 21:35:39 +00:00
copy_alloc.pass.cpp Guard libc++ specific c.__invariants() tests in LIBCPP_ASSERT macros 2016-04-28 22:28:23 +00:00
default.recursive.pass.cpp
default_noexcept.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
dtor_noexcept.pass.cpp Make dtor_noexcept.pass.cpp tests more portable. Patch from STL@microsoft.com 2016-07-25 00:50:32 +00:00
initializer_list.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
initializer_list_alloc.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
move.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
move_alloc.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
move_assign_noexcept.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
move_noexcept.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
op_equal_initializer_list.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00