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:
Howard Hinnant
2013-06-28 16:59:19 +00:00
parent 2c39cbe020
commit 9dcdcdee25
151 changed files with 5125 additions and 645 deletions

View File

@@ -17,6 +17,7 @@
#include <cassert>
#include "../test_allocator.h"
#include "../min_allocator.h"
template <class charT>
void
@@ -34,13 +35,12 @@ test(const charT* s)
assert(s2.capacity() >= s2.size());
}
template <class charT>
template <class charT, class A>
void
test(const charT* s, const test_allocator<charT>& a)
test(const charT* s, 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;
unsigned n = T::length(s);
S s2(s, a);
assert(s2.__invariants());
@@ -52,6 +52,7 @@ test(const charT* s, const test_allocator<charT>& a)
int main()
{
{
typedef test_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
@@ -66,4 +67,23 @@ int main()
test("123456798012345679801234567980123456798012345679801234567980");
test("123456798012345679801234567980123456798012345679801234567980", A(2));
}
#if __cplusplus >= 201103L
{
typedef min_allocator<char> A;
typedef std::basic_string<char, std::char_traits<char>, A> S;
test("");
test("", A());
test("1");
test("1", A());
test("1234567980");
test("1234567980", A());
test("123456798012345679801234567980123456798012345679801234567980");
test("123456798012345679801234567980123456798012345679801234567980", A());
}
#endif
}