Implement full support for non-pointer pointers in custom allocators for vector.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@185093 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include "test_iterators.h"
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -51,4 +52,38 @@ int main()
|
||||
for (; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
bool a[] = {1, 0, 0, 1, 1};
|
||||
const unsigned N = sizeof(a)/sizeof(a[0]);
|
||||
std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
|
||||
input_iterator<const bool*>(a+N));
|
||||
assert(v.size() == 100 + N);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (int k = 0; k < N; ++j, ++k)
|
||||
assert(v[j] == a[k]);
|
||||
for (; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
{
|
||||
std::vector<bool, min_allocator<bool>> v(100);
|
||||
bool a[] = {1, 0, 0, 1, 1};
|
||||
const unsigned N = sizeof(a)/sizeof(a[0]);
|
||||
std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
|
||||
forward_iterator<const bool*>(a+N));
|
||||
assert(v.size() == 100 + N);
|
||||
assert(i == v.begin() + 10);
|
||||
int j;
|
||||
for (j = 0; j < 10; ++j)
|
||||
assert(v[j] == 0);
|
||||
for (int k = 0; k < N; ++j, ++k)
|
||||
assert(v[j] == a[k]);
|
||||
for (; j < 105; ++j)
|
||||
assert(v[j] == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user