Implement full support for non-pointer pointers in custom allocators for string. This completes the custom pointer support for the entire library.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@185167 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <cassert>
|
||||
|
||||
#include "../test_allocator.h"
|
||||
#include "../min_allocator.h"
|
||||
|
||||
template <class charT>
|
||||
void
|
||||
@@ -33,13 +34,12 @@ test(const charT* s, unsigned n)
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
template <class charT>
|
||||
template <class charT, class A>
|
||||
void
|
||||
test(const charT* s, unsigned n, const test_allocator<charT>& a)
|
||||
test(const charT* s, unsigned n, const A& a)
|
||||
{
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
typedef typename S::traits_type T;
|
||||
typedef typename S::allocator_type A;
|
||||
S s2(s, n, a);
|
||||
assert(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
@@ -50,6 +50,7 @@ test(const charT* s, unsigned n, const test_allocator<charT>& a)
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
|
||||
@@ -64,4 +65,23 @@ int main()
|
||||
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60);
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60, A(2));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
|
||||
test("", 0);
|
||||
test("", 0, A());
|
||||
|
||||
test("1", 1);
|
||||
test("1", 1, A());
|
||||
|
||||
test("1234567980", 10);
|
||||
test("1234567980", 10, A());
|
||||
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60);
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60, A());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user