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:
@@ -20,6 +20,14 @@
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
struct A
|
||||
{
|
||||
int first;
|
||||
int second;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -69,4 +77,62 @@ int main()
|
||||
C::iterator i;
|
||||
C::const_iterator j;
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c;
|
||||
C::iterator i = c.begin();
|
||||
C::iterator j = c.end();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
const C c;
|
||||
C::const_iterator i = c.begin();
|
||||
C::const_iterator j = c.end();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c;
|
||||
C::const_iterator i = c.cbegin();
|
||||
C::const_iterator j = c.cend();
|
||||
assert(std::distance(i, j) == 0);
|
||||
assert(i == j);
|
||||
assert(i == c.end());
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
C c(std::begin(t), std::end(t));
|
||||
C::iterator i = c.begin();
|
||||
assert(*i == 0);
|
||||
++i;
|
||||
assert(*i == 1);
|
||||
*i = 10;
|
||||
assert(*i == 10);
|
||||
assert(std::distance(c.begin(), c.end()) == 10);
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C::iterator i;
|
||||
C::const_iterator j;
|
||||
}
|
||||
{
|
||||
typedef A T;
|
||||
typedef std::vector<T, min_allocator<T>> C;
|
||||
C c = {A{1, 2}};
|
||||
C::iterator i = c.begin();
|
||||
i->first = 3;
|
||||
C::const_iterator j = i;
|
||||
assert(j->first == 3);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user