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

@@ -15,6 +15,7 @@
#include <cassert>
#include "../test_allocator.h"
#include "../min_allocator.h"
template <class S>
void
@@ -36,6 +37,7 @@ test(S s)
int main()
{
{
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > S;
S s;
test(s);
@@ -45,4 +47,12 @@ int main()
s.assign(100, 'a');
s.erase(50);
test(s);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s;
assert(s.capacity() > 0);
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -24,6 +26,7 @@ test(S s)
int main()
{
{
typedef std::string S;
S s;
test(s);
@@ -35,4 +38,20 @@ int main()
s.assign(100, 'a');
s.erase(50);
test(s);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s;
test(s);
s.assign(10, 'a');
s.erase(5);
test(s);
s.assign(100, 'a');
s.erase(50);
test(s);
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s)
@@ -23,8 +25,18 @@ test(const S& s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s)
@@ -23,8 +25,18 @@ test(const S& s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s)
@@ -23,8 +25,18 @@ test(const S& s)
int main()
{
{
typedef std::string S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S());
test(S("123"));
test(S("12345678901234567890123456789012345678901234567890"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <stdexcept>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -50,6 +52,7 @@ test(S s, typename S::size_type res_arg)
int main()
{
{
typedef std::string S;
{
S s;
@@ -78,4 +81,37 @@ int main()
test(s, 100);
test(s, S::npos);
}
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
{
S s;
test(s);
s.assign(10, 'a');
s.erase(5);
test(s);
s.assign(100, 'a');
s.erase(50);
test(s);
}
{
S s;
test(s, 5);
test(s, 10);
test(s, 50);
}
{
S s(100, 'a');
s.erase(50);
test(s, 5);
test(s, 10);
test(s, 50);
test(s, 100);
test(s, S::npos);
}
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <stdexcept>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s, typename S::size_type n, S expected)
@@ -34,6 +36,7 @@ test(S s, typename S::size_type n, S expected)
int main()
{
{
typedef std::string S;
test(S(), 0, S());
test(S(), 1, S(1, '\0'));
@@ -51,4 +54,26 @@ int main()
test(S("12345678901234567890123456789012345678901234567890"), 60,
S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60));
test(S(), S::npos, S("not going to happen"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), 0, S());
test(S(), 1, S(1, '\0'));
test(S(), 10, S(10, '\0'));
test(S(), 100, S(100, '\0'));
test(S("12345"), 0, S());
test(S("12345"), 2, S("12"));
test(S("12345"), 5, S("12345"));
test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15));
test(S("12345678901234567890123456789012345678901234567890"), 0, S());
test(S("12345678901234567890123456789012345678901234567890"), 10,
S("1234567890"));
test(S("12345678901234567890123456789012345678901234567890"), 50,
S("12345678901234567890123456789012345678901234567890"));
test(S("12345678901234567890123456789012345678901234567890"), 60,
S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60));
test(S(), S::npos, S("not going to happen"));
}
#endif
}

View File

@@ -15,6 +15,8 @@
#include <stdexcept>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s, typename S::size_type n, typename S::value_type c, S expected)
@@ -34,6 +36,7 @@ test(S s, typename S::size_type n, typename S::value_type c, S expected)
int main()
{
{
typedef std::string S;
test(S(), 0, 'a', S());
test(S(), 1, 'a', S("a"));
@@ -51,4 +54,26 @@ int main()
test(S("12345678901234567890123456789012345678901234567890"), 60, 'a',
S("12345678901234567890123456789012345678901234567890aaaaaaaaaa"));
test(S(), S::npos, 'a', S("not going to happen"));
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), 0, 'a', S());
test(S(), 1, 'a', S("a"));
test(S(), 10, 'a', S(10, 'a'));
test(S(), 100, 'a', S(100, 'a'));
test(S("12345"), 0, 'a', S());
test(S("12345"), 2, 'a', S("12"));
test(S("12345"), 5, 'a', S("12345"));
test(S("12345"), 15, 'a', S("12345aaaaaaaaaa"));
test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S());
test(S("12345678901234567890123456789012345678901234567890"), 10, 'a',
S("1234567890"));
test(S("12345678901234567890123456789012345678901234567890"), 50, 'a',
S("12345678901234567890123456789012345678901234567890"));
test(S("12345678901234567890123456789012345678901234567890"), 60, 'a',
S("12345678901234567890123456789012345678901234567890aaaaaaaaaa"));
test(S(), S::npos, 'a', S("not going to happen"));
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(S s)
@@ -29,6 +31,7 @@ test(S s)
int main()
{
{
typedef std::string S;
S s;
test(s);
@@ -40,4 +43,20 @@ int main()
s.assign(100, 'a');
s.erase(50);
test(s);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s;
test(s);
s.assign(10, 'a');
s.erase(5);
test(s);
s.assign(100, 'a');
s.erase(50);
test(s);
}
#endif
}

View File

@@ -14,6 +14,8 @@
#include <string>
#include <cassert>
#include "../min_allocator.h"
template <class S>
void
test(const S& s, typename S::size_type c)
@@ -23,8 +25,18 @@ test(const S& s, typename S::size_type c)
int main()
{
{
typedef std::string S;
test(S(), 0);
test(S("123"), 3);
test(S("12345678901234567890123456789012345678901234567890"), 50);
}
#if __cplusplus >= 201103L
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), 0);
test(S("123"), 3);
test(S("12345678901234567890123456789012345678901234567890"), 50);
}
#endif
}