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:
@@ -14,6 +14,8 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& s, typename S::value_type c, typename S::size_type pos,
|
||||
@@ -33,10 +35,10 @@ test(const S& s, typename S::value_type c, typename S::size_type x)
|
||||
assert(x < s.size());
|
||||
}
|
||||
|
||||
typedef std::string S;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(""), 'i', 0, S::npos);
|
||||
test(S(""), 'i', 1, S::npos);
|
||||
test(S("kitcj"), 'i', 0, 0);
|
||||
@@ -62,4 +64,35 @@ int main()
|
||||
test(S("csope"), 'i', 4);
|
||||
test(S("gfsmthlkon"), 'i', 9);
|
||||
test(S("laenfsbridchgotmkqpj"), 'i', 19);
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(""), 'i', 0, S::npos);
|
||||
test(S(""), 'i', 1, S::npos);
|
||||
test(S("kitcj"), 'i', 0, 0);
|
||||
test(S("qkamf"), 'i', 1, 1);
|
||||
test(S("nhmko"), 'i', 2, 2);
|
||||
test(S("tpsaf"), 'i', 4, 4);
|
||||
test(S("lahfb"), 'i', 5, 4);
|
||||
test(S("irkhs"), 'i', 6, 4);
|
||||
test(S("gmfhdaipsr"), 'i', 0, 0);
|
||||
test(S("kantesmpgj"), 'i', 1, 1);
|
||||
test(S("odaftiegpm"), 'i', 5, 4);
|
||||
test(S("oknlrstdpi"), 'i', 9, 8);
|
||||
test(S("eolhfgpjqk"), 'i', 10, 9);
|
||||
test(S("pcdrofikas"), 'i', 11, 9);
|
||||
test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
|
||||
test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
|
||||
test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
|
||||
test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
|
||||
test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
|
||||
test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
|
||||
|
||||
test(S(""), 'i', S::npos);
|
||||
test(S("csope"), 'i', 4);
|
||||
test(S("gfsmthlkon"), 'i', 9);
|
||||
test(S("laenfsbridchgotmkqpj"), 'i', 19);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& s, const typename S::value_type* str, typename S::size_type pos,
|
||||
@@ -33,8 +35,7 @@ test(const S& s, const typename S::value_type* str, typename S::size_type x)
|
||||
assert(x < s.size());
|
||||
}
|
||||
|
||||
typedef std::string S;
|
||||
|
||||
template <class S>
|
||||
void test0()
|
||||
{
|
||||
test(S(""), "", 0, S::npos);
|
||||
@@ -119,6 +120,7 @@ void test0()
|
||||
test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test1()
|
||||
{
|
||||
test(S(""), "", S::npos);
|
||||
@@ -141,6 +143,16 @@ void test1()
|
||||
|
||||
int main()
|
||||
{
|
||||
test0();
|
||||
test1();
|
||||
{
|
||||
typedef std::string S;
|
||||
test0<S>();
|
||||
test1<S>();
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test0<S>();
|
||||
test1<S>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& s, const typename S::value_type* str, typename S::size_type pos,
|
||||
@@ -24,8 +26,7 @@ test(const S& s, const typename S::value_type* str, typename S::size_type pos,
|
||||
assert(x <= pos && x < s.size());
|
||||
}
|
||||
|
||||
typedef std::string S;
|
||||
|
||||
template <class S>
|
||||
void test0()
|
||||
{
|
||||
test(S(""), "", 0, 0, S::npos);
|
||||
@@ -130,6 +131,7 @@ void test0()
|
||||
test(S("hkjae"), "dfsmk", 5, 2, 4);
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test1()
|
||||
{
|
||||
test(S("gbhqo"), "skqne", 5, 4, 4);
|
||||
@@ -234,6 +236,7 @@ void test1()
|
||||
test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 9);
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test2()
|
||||
{
|
||||
test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 8);
|
||||
@@ -338,6 +341,7 @@ void test2()
|
||||
test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, 19);
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test3()
|
||||
{
|
||||
test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 19);
|
||||
@@ -364,8 +368,20 @@ void test3()
|
||||
|
||||
int main()
|
||||
{
|
||||
test0();
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
{
|
||||
typedef std::string S;
|
||||
test0<S>();
|
||||
test1<S>();
|
||||
test2<S>();
|
||||
test3<S>();
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test0<S>();
|
||||
test1<S>();
|
||||
test2<S>();
|
||||
test3<S>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "../../min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
|
||||
@@ -32,8 +34,7 @@ test(const S& s, const S& str, typename S::size_type x)
|
||||
assert(x < s.size());
|
||||
}
|
||||
|
||||
typedef std::string S;
|
||||
|
||||
template <class S>
|
||||
void test0()
|
||||
{
|
||||
test(S(""), S(""), 0, S::npos);
|
||||
@@ -118,6 +119,7 @@ void test0()
|
||||
test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void test1()
|
||||
{
|
||||
test(S(""), S(""), S::npos);
|
||||
@@ -140,6 +142,16 @@ void test1()
|
||||
|
||||
int main()
|
||||
{
|
||||
test0();
|
||||
test1();
|
||||
{
|
||||
typedef std::string S;
|
||||
test0<S>();
|
||||
test1<S>();
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test0<S>();
|
||||
test1<S>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user