libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static void assign(char_type& c1, const char_type& c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
char c = '\0';
|
||||
std::char_traits<char>::assign(c, 'a');
|
||||
assert(c == 'a');
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static char_type* assign(char_type* s, size_t n, char_type a);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
char s1[] = {1, 2, 3};
|
||||
char s2[3] = {0};
|
||||
assert(std::char_traits<char>::assign(s2, 3, char(5)) == s2);
|
||||
assert(s2[0] == char(5));
|
||||
assert(s2[1] == char(5));
|
||||
assert(s2[2] == char(5));
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static int compare(const char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<char>::compare("", "", 0) == 0);
|
||||
|
||||
assert(std::char_traits<char>::compare("1", "1", 1) == 0);
|
||||
assert(std::char_traits<char>::compare("1", "2", 1) < 0);
|
||||
assert(std::char_traits<char>::compare("2", "1", 1) > 0);
|
||||
|
||||
assert(std::char_traits<char>::compare("12", "12", 2) == 0);
|
||||
assert(std::char_traits<char>::compare("12", "13", 2) < 0);
|
||||
assert(std::char_traits<char>::compare("12", "22", 2) < 0);
|
||||
assert(std::char_traits<char>::compare("13", "12", 2) > 0);
|
||||
assert(std::char_traits<char>::compare("22", "12", 2) > 0);
|
||||
|
||||
assert(std::char_traits<char>::compare("123", "123", 3) == 0);
|
||||
assert(std::char_traits<char>::compare("123", "223", 3) < 0);
|
||||
assert(std::char_traits<char>::compare("123", "133", 3) < 0);
|
||||
assert(std::char_traits<char>::compare("123", "124", 3) < 0);
|
||||
assert(std::char_traits<char>::compare("223", "123", 3) > 0);
|
||||
assert(std::char_traits<char>::compare("133", "123", 3) > 0);
|
||||
assert(std::char_traits<char>::compare("124", "123", 3) > 0);
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
char s1[] = {1, 2, 3};
|
||||
char s2[3] = {0};
|
||||
assert(std::char_traits<char>::copy(s2, s1, 3) == s2);
|
||||
assert(s2[0] == char(1));
|
||||
assert(s2[1] == char(2));
|
||||
assert(s2[2] == char(3));
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static constexpr int_type eof();
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<char>::eof() == EOF);
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static constexpr bool eq(char_type c1, char_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
char c = '\0';
|
||||
assert(std::char_traits<char>::eq('a', 'a'));
|
||||
assert(!std::char_traits<char>::eq('a', 'A'));
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static constexpr bool eq_int_type(int_type c1, int_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert( std::char_traits<char>::eq_int_type('a', 'a'));
|
||||
assert(!std::char_traits<char>::eq_int_type('a', 'A'));
|
||||
assert(!std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(), 'A'));
|
||||
assert( std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(),
|
||||
std::char_traits<char>::eof()));
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static const char_type* find(const char_type* s, size_t n, const char_type& a);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
char s1[] = {1, 2, 3};
|
||||
assert(std::char_traits<char>::find(s1, 3, char(1)) == s1);
|
||||
assert(std::char_traits<char>::find(s1, 3, char(2)) == s1+1);
|
||||
assert(std::char_traits<char>::find(s1, 3, char(3)) == s1+2);
|
||||
assert(std::char_traits<char>::find(s1, 3, char(4)) == 0);
|
||||
assert(std::char_traits<char>::find(s1, 3, char(0)) == 0);
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static size_t length(const char_type* s);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<char>::length("") == 0);
|
||||
assert(std::char_traits<char>::length("a") == 1);
|
||||
assert(std::char_traits<char>::length("aa") == 2);
|
||||
assert(std::char_traits<char>::length("aaa") == 3);
|
||||
assert(std::char_traits<char>::length("aaaa") == 4);
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static constexpr bool lt(char_type c1, char_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
char c = '\0';
|
||||
assert(!std::char_traits<char>::lt('a', 'a'));
|
||||
assert( std::char_traits<char>::lt('A', 'a'));
|
||||
assert(!std::char_traits<char>::lt('A' + 127, 'a'));
|
||||
assert(!std::char_traits<char>::lt('A' - 127, 'a'));
|
||||
assert( std::char_traits<char>::lt('A', 'a' + 127));
|
||||
assert( std::char_traits<char>::lt('A', 'a' - 127));
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static char_type* move(char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
char s1[] = {1, 2, 3};
|
||||
assert(std::char_traits<char>::move(s1, s1+1, 2) == s1);
|
||||
assert(s1[0] == char(2));
|
||||
assert(s1[1] == char(3));
|
||||
assert(s1[2] == char(3));
|
||||
s1[2] = char(0);
|
||||
assert(std::char_traits<char>::move(s1+1, s1, 2) == s1+1);
|
||||
assert(s1[0] == char(2));
|
||||
assert(s1[1] == char(2));
|
||||
assert(s1[2] == char(3));
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static constexpr int_type not_eof(int_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<char>::not_eof('a') == 'a');
|
||||
assert(std::char_traits<char>::not_eof('A') == 'A');
|
||||
assert(std::char_traits<char>::not_eof(0) == 0);
|
||||
assert(std::char_traits<char>::not_eof(std::char_traits<char>::eof()) !=
|
||||
std::char_traits<char>::eof());
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static constexpr char_type to_char_type(int_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<char>::to_char_type('a') == 'a');
|
||||
assert(std::char_traits<char>::to_char_type('A') == 'A');
|
||||
assert(std::char_traits<char>::to_char_type(0) == 0);
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// static constexpr int_type to_int_type(char_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<char>::to_int_type('a') == 'a');
|
||||
assert(std::char_traits<char>::to_int_type('A') == 'A');
|
||||
assert(std::char_traits<char>::to_int_type(0) == 0);
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char>
|
||||
|
||||
// typedef char char_type;
|
||||
// typedef int int_type;
|
||||
// typedef streamoff off_type;
|
||||
// typedef streampos pos_type;
|
||||
// typedef mbstate_t state_type;
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_same<std::char_traits<char>::char_type, char>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char>::int_type, int>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char>::off_type, std::streamoff>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char>::pos_type, std::streampos>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char>::state_type, std::mbstate_t>::value), "");
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static void assign(char_type& c1, const char_type& c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char16_t c = u'\0';
|
||||
std::char_traits<char16_t>::assign(c, u'a');
|
||||
assert(c == u'a');
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static char_type* assign(char_type* s, size_t n, char_type a);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char16_t s1[] = {1, 2, 3};
|
||||
char16_t s2[3] = {0};
|
||||
assert(std::char_traits<char16_t>::assign(s2, 3, char16_t(5)) == s2);
|
||||
assert(s2[0] == char16_t(5));
|
||||
assert(s2[1] == char16_t(5));
|
||||
assert(s2[2] == char16_t(5));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static int compare(const char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert(std::char_traits<char16_t>::compare(u"", u"", 0) == 0);
|
||||
|
||||
assert(std::char_traits<char16_t>::compare(u"1", u"1", 1) == 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"1", u"2", 1) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"2", u"1", 1) > 0);
|
||||
|
||||
assert(std::char_traits<char16_t>::compare(u"12", u"12", 2) == 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"12", u"13", 2) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"12", u"22", 2) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"13", u"12", 2) > 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"22", u"12", 2) > 0);
|
||||
|
||||
assert(std::char_traits<char16_t>::compare(u"123", u"123", 3) == 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"123", u"223", 3) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"123", u"133", 3) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"123", u"124", 3) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"223", u"123", 3) > 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"133", u"123", 3) > 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"124", u"123", 3) > 0);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char16_t s1[] = {1, 2, 3};
|
||||
char16_t s2[3] = {0};
|
||||
assert(std::char_traits<char16_t>::copy(s2, s1, 3) == s2);
|
||||
assert(s2[0] == char16_t(1));
|
||||
assert(s2[1] == char16_t(2));
|
||||
assert(s2[2] == char16_t(3));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static constexpr int_type eof();
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
std::char_traits<char16_t>::int_type i = std::char_traits<char16_t>::eof();
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static constexpr bool eq(char_type c1, char_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char16_t c = u'\0';
|
||||
assert(std::char_traits<char16_t>::eq(u'a', u'a'));
|
||||
assert(!std::char_traits<char16_t>::eq(u'a', u'A'));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static constexpr bool eq_int_type(int_type c1, int_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert( std::char_traits<char16_t>::eq_int_type(u'a', u'a'));
|
||||
assert(!std::char_traits<char16_t>::eq_int_type(u'a', u'A'));
|
||||
assert(!std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(), u'A'));
|
||||
assert( std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(),
|
||||
std::char_traits<char16_t>::eof()));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static const char_type* find(const char_type* s, size_t n, const char_type& a);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char16_t s1[] = {1, 2, 3};
|
||||
assert(std::char_traits<char16_t>::find(s1, 3, char16_t(1)) == s1);
|
||||
assert(std::char_traits<char16_t>::find(s1, 3, char16_t(2)) == s1+1);
|
||||
assert(std::char_traits<char16_t>::find(s1, 3, char16_t(3)) == s1+2);
|
||||
assert(std::char_traits<char16_t>::find(s1, 3, char16_t(4)) == 0);
|
||||
assert(std::char_traits<char16_t>::find(s1, 3, char16_t(0)) == 0);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static size_t length(const char_type* s);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert(std::char_traits<char16_t>::length(u"") == 0);
|
||||
assert(std::char_traits<char16_t>::length(u"a") == 1);
|
||||
assert(std::char_traits<char16_t>::length(u"aa") == 2);
|
||||
assert(std::char_traits<char16_t>::length(u"aaa") == 3);
|
||||
assert(std::char_traits<char16_t>::length(u"aaaa") == 4);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static constexpr bool lt(char_type c1, char_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char16_t c = u'\0';
|
||||
assert(!std::char_traits<char16_t>::lt(u'a', u'a'));
|
||||
assert( std::char_traits<char16_t>::lt(u'A', u'a'));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static char_type* move(char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char16_t s1[] = {1, 2, 3};
|
||||
assert(std::char_traits<char16_t>::move(s1, s1+1, 2) == s1);
|
||||
assert(s1[0] == char16_t(2));
|
||||
assert(s1[1] == char16_t(3));
|
||||
assert(s1[2] == char16_t(3));
|
||||
s1[2] = char16_t(0);
|
||||
assert(std::char_traits<char16_t>::move(s1+1, s1, 2) == s1+1);
|
||||
assert(s1[0] == char16_t(2));
|
||||
assert(s1[1] == char16_t(2));
|
||||
assert(s1[2] == char16_t(3));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static constexpr int_type not_eof(int_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert(std::char_traits<char16_t>::not_eof(u'a') == u'a');
|
||||
assert(std::char_traits<char16_t>::not_eof(u'A') == u'A');
|
||||
assert(std::char_traits<char16_t>::not_eof(0) == 0);
|
||||
assert(std::char_traits<char16_t>::not_eof(std::char_traits<char16_t>::eof()) !=
|
||||
std::char_traits<char16_t>::eof());
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static constexpr char_type to_char_type(int_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert(std::char_traits<char16_t>::to_char_type(u'a') == u'a');
|
||||
assert(std::char_traits<char16_t>::to_char_type(u'A') == u'A');
|
||||
assert(std::char_traits<char16_t>::to_char_type(0) == 0);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static constexpr int_type to_int_type(char_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert(std::char_traits<char16_t>::to_int_type(u'a') == u'a');
|
||||
assert(std::char_traits<char16_t>::to_int_type(u'A') == u'A');
|
||||
assert(std::char_traits<char16_t>::to_int_type(0) == 0);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// typedef char16_t char_type;
|
||||
// typedef uint_least16_t int_type;
|
||||
// typedef streamoff off_type;
|
||||
// typedef u16streampos pos_type;
|
||||
// typedef mbstate_t state_type;
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <cstdint>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
static_assert((std::is_same<std::char_traits<char16_t>::char_type, char16_t>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char16_t>::int_type, std::uint_least16_t>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char16_t>::off_type, std::streamoff>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char16_t>::pos_type, std::u16streampos>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char16_t>::state_type, std::mbstate_t>::value), "");
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static void assign(char_type& c1, const char_type& c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char32_t c = U'\0';
|
||||
std::char_traits<char32_t>::assign(c, U'a');
|
||||
assert(c == U'a');
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static char_type* assign(char_type* s, size_t n, char_type a);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char32_t s1[] = {1, 2, 3};
|
||||
char32_t s2[3] = {0};
|
||||
assert(std::char_traits<char32_t>::assign(s2, 3, char32_t(5)) == s2);
|
||||
assert(s2[0] == char32_t(5));
|
||||
assert(s2[1] == char32_t(5));
|
||||
assert(s2[2] == char32_t(5));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static int compare(const char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert(std::char_traits<char32_t>::compare(U"", U"", 0) == 0);
|
||||
|
||||
assert(std::char_traits<char32_t>::compare(U"1", U"1", 1) == 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"1", U"2", 1) < 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"2", U"1", 1) > 0);
|
||||
|
||||
assert(std::char_traits<char32_t>::compare(U"12", U"12", 2) == 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"12", U"13", 2) < 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"12", U"22", 2) < 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"13", U"12", 2) > 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"22", U"12", 2) > 0);
|
||||
|
||||
assert(std::char_traits<char32_t>::compare(U"123", U"123", 3) == 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"123", U"223", 3) < 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"123", U"133", 3) < 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"123", U"124", 3) < 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"223", U"123", 3) > 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"133", U"123", 3) > 0);
|
||||
assert(std::char_traits<char32_t>::compare(U"124", U"123", 3) > 0);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char32_t s1[] = {1, 2, 3};
|
||||
char32_t s2[3] = {0};
|
||||
assert(std::char_traits<char32_t>::copy(s2, s1, 3) == s2);
|
||||
assert(s2[0] == char32_t(1));
|
||||
assert(s2[1] == char32_t(2));
|
||||
assert(s2[2] == char32_t(3));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static constexpr int_type eof();
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
std::char_traits<char32_t>::int_type i = std::char_traits<char32_t>::eof();
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static constexpr bool eq(char_type c1, char_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char32_t c = U'\0';
|
||||
assert(std::char_traits<char32_t>::eq(U'a', U'a'));
|
||||
assert(!std::char_traits<char32_t>::eq(U'a', U'A'));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static constexpr bool eq_int_type(int_type c1, int_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert( std::char_traits<char32_t>::eq_int_type(U'a', U'a'));
|
||||
assert(!std::char_traits<char32_t>::eq_int_type(U'a', U'A'));
|
||||
assert(!std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(), U'A'));
|
||||
assert( std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(),
|
||||
std::char_traits<char32_t>::eof()));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static const char_type* find(const char_type* s, size_t n, const char_type& a);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char32_t s1[] = {1, 2, 3};
|
||||
assert(std::char_traits<char32_t>::find(s1, 3, char32_t(1)) == s1);
|
||||
assert(std::char_traits<char32_t>::find(s1, 3, char32_t(2)) == s1+1);
|
||||
assert(std::char_traits<char32_t>::find(s1, 3, char32_t(3)) == s1+2);
|
||||
assert(std::char_traits<char32_t>::find(s1, 3, char32_t(4)) == 0);
|
||||
assert(std::char_traits<char32_t>::find(s1, 3, char32_t(0)) == 0);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static size_t length(const char_type* s);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert(std::char_traits<char32_t>::length(U"") == 0);
|
||||
assert(std::char_traits<char32_t>::length(U"a") == 1);
|
||||
assert(std::char_traits<char32_t>::length(U"aa") == 2);
|
||||
assert(std::char_traits<char32_t>::length(U"aaa") == 3);
|
||||
assert(std::char_traits<char32_t>::length(U"aaaa") == 4);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static constexpr bool lt(char_type c1, char_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char32_t c = U'\0';
|
||||
assert(!std::char_traits<char32_t>::lt(U'a', U'a'));
|
||||
assert( std::char_traits<char32_t>::lt(U'A', U'a'));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static char_type* move(char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char32_t s1[] = {1, 2, 3};
|
||||
assert(std::char_traits<char32_t>::move(s1, s1+1, 2) == s1);
|
||||
assert(s1[0] == char32_t(2));
|
||||
assert(s1[1] == char32_t(3));
|
||||
assert(s1[2] == char32_t(3));
|
||||
s1[2] = char32_t(0);
|
||||
assert(std::char_traits<char32_t>::move(s1+1, s1, 2) == s1+1);
|
||||
assert(s1[0] == char32_t(2));
|
||||
assert(s1[1] == char32_t(2));
|
||||
assert(s1[2] == char32_t(3));
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static constexpr int_type not_eof(int_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert(std::char_traits<char32_t>::not_eof(U'a') == U'a');
|
||||
assert(std::char_traits<char32_t>::not_eof(U'A') == U'A');
|
||||
assert(std::char_traits<char32_t>::not_eof(0) == 0);
|
||||
assert(std::char_traits<char32_t>::not_eof(std::char_traits<char32_t>::eof()) !=
|
||||
std::char_traits<char32_t>::eof());
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static constexpr char_type to_char_type(int_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert(std::char_traits<char32_t>::to_char_type(U'a') == U'a');
|
||||
assert(std::char_traits<char32_t>::to_char_type(U'A') == U'A');
|
||||
assert(std::char_traits<char32_t>::to_char_type(0) == 0);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// static constexpr int_type to_int_type(char_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
assert(std::char_traits<char32_t>::to_int_type(U'a') == U'a');
|
||||
assert(std::char_traits<char32_t>::to_int_type(U'A') == U'A');
|
||||
assert(std::char_traits<char32_t>::to_int_type(0) == 0);
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char32_t>
|
||||
|
||||
// typedef char32_t char_type;
|
||||
// typedef uint_least32_t int_type;
|
||||
// typedef streamoff off_type;
|
||||
// typedef u32streampos pos_type;
|
||||
// typedef mbstate_t state_type;
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <cstdint>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
static_assert((std::is_same<std::char_traits<char32_t>::char_type, char32_t>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char32_t>::int_type, std::uint_least32_t>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char32_t>::off_type, std::streamoff>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char32_t>::pos_type, std::u32streampos>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<char32_t>::state_type, std::mbstate_t>::value), "");
|
||||
#endif
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static void assign(char_type& c1, const char_type& c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
wchar_t c = L'\0';
|
||||
std::char_traits<wchar_t>::assign(c, L'a');
|
||||
assert(c == L'a');
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static char_type* assign(char_type* s, size_t n, char_type a);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
wchar_t s1[] = {1, 2, 3};
|
||||
wchar_t s2[3] = {0};
|
||||
assert(std::char_traits<wchar_t>::assign(s2, 3, wchar_t(5)) == s2);
|
||||
assert(s2[0] == wchar_t(5));
|
||||
assert(s2[1] == wchar_t(5));
|
||||
assert(s2[2] == wchar_t(5));
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static int compare(const char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<wchar_t>::compare(L"", L"", 0) == 0);
|
||||
|
||||
assert(std::char_traits<wchar_t>::compare(L"1", L"1", 1) == 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"1", L"2", 1) < 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"2", L"1", 1) > 0);
|
||||
|
||||
assert(std::char_traits<wchar_t>::compare(L"12", L"12", 2) == 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"12", L"13", 2) < 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"12", L"22", 2) < 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"13", L"12", 2) > 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"22", L"12", 2) > 0);
|
||||
|
||||
assert(std::char_traits<wchar_t>::compare(L"123", L"123", 3) == 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"123", L"223", 3) < 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"123", L"133", 3) < 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"123", L"124", 3) < 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"223", L"123", 3) > 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"133", L"123", 3) > 0);
|
||||
assert(std::char_traits<wchar_t>::compare(L"124", L"123", 3) > 0);
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
wchar_t s1[] = {1, 2, 3};
|
||||
wchar_t s2[3] = {0};
|
||||
assert(std::char_traits<wchar_t>::copy(s2, s1, 3) == s2);
|
||||
assert(s2[0] == wchar_t(1));
|
||||
assert(s2[1] == wchar_t(2));
|
||||
assert(s2[2] == wchar_t(3));
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static constexpr int_type eof();
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<wchar_t>::eof() == WEOF);
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static constexpr bool eq(char_type c1, char_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
wchar_t c = L'\0';
|
||||
assert(std::char_traits<wchar_t>::eq(L'a', L'a'));
|
||||
assert(!std::char_traits<wchar_t>::eq(L'a', L'A'));
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static constexpr bool eq_int_type(int_type c1, int_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert( std::char_traits<wchar_t>::eq_int_type(L'a', L'a'));
|
||||
assert(!std::char_traits<wchar_t>::eq_int_type(L'a', L'A'));
|
||||
assert(!std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(), L'A'));
|
||||
assert( std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(),
|
||||
std::char_traits<wchar_t>::eof()));
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static const char_type* find(const char_type* s, size_t n, const char_type& a);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
wchar_t s1[] = {1, 2, 3};
|
||||
assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(1)) == s1);
|
||||
assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(2)) == s1+1);
|
||||
assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(3)) == s1+2);
|
||||
assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(4)) == 0);
|
||||
assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(0)) == 0);
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static size_t length(const char_type* s);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<wchar_t>::length(L"") == 0);
|
||||
assert(std::char_traits<wchar_t>::length(L"a") == 1);
|
||||
assert(std::char_traits<wchar_t>::length(L"aa") == 2);
|
||||
assert(std::char_traits<wchar_t>::length(L"aaa") == 3);
|
||||
assert(std::char_traits<wchar_t>::length(L"aaaa") == 4);
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static constexpr bool lt(char_type c1, char_type c2);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
wchar_t c = L'\0';
|
||||
assert(!std::char_traits<wchar_t>::lt(L'a', L'a'));
|
||||
assert( std::char_traits<wchar_t>::lt(L'A', L'a'));
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static char_type* move(char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
wchar_t s1[] = {1, 2, 3};
|
||||
assert(std::char_traits<wchar_t>::move(s1, s1+1, 2) == s1);
|
||||
assert(s1[0] == wchar_t(2));
|
||||
assert(s1[1] == wchar_t(3));
|
||||
assert(s1[2] == wchar_t(3));
|
||||
s1[2] = wchar_t(0);
|
||||
assert(std::char_traits<wchar_t>::move(s1+1, s1, 2) == s1+1);
|
||||
assert(s1[0] == wchar_t(2));
|
||||
assert(s1[1] == wchar_t(2));
|
||||
assert(s1[2] == wchar_t(3));
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static constexpr int_type not_eof(int_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<wchar_t>::not_eof(L'a') == L'a');
|
||||
assert(std::char_traits<wchar_t>::not_eof(L'A') == L'A');
|
||||
assert(std::char_traits<wchar_t>::not_eof(0) == 0);
|
||||
assert(std::char_traits<wchar_t>::not_eof(std::char_traits<wchar_t>::eof()) !=
|
||||
std::char_traits<wchar_t>::eof());
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static constexpr char_type to_char_type(int_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<wchar_t>::to_char_type(L'a') == L'a');
|
||||
assert(std::char_traits<wchar_t>::to_char_type(L'A') == L'A');
|
||||
assert(std::char_traits<wchar_t>::to_char_type(0) == 0);
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// static constexpr int_type to_int_type(char_type c);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::char_traits<wchar_t>::to_int_type(L'a') == L'a');
|
||||
assert(std::char_traits<wchar_t>::to_int_type(L'A') == L'A');
|
||||
assert(std::char_traits<wchar_t>::to_int_type(0) == 0);
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<wchar_t>
|
||||
|
||||
// typedef wchar_t char_type;
|
||||
// typedef int int_type;
|
||||
// typedef streamoff off_type;
|
||||
// typedef streampos pos_type;
|
||||
// typedef mbstate_t state_type;
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_same<std::char_traits<wchar_t>::char_type, wchar_t>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<wchar_t>::int_type, std::wint_t>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<wchar_t>::off_type, std::streamoff>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<wchar_t>::pos_type, std::wstreampos>::value), "");
|
||||
static_assert((std::is_same<std::char_traits<wchar_t>::state_type, std::mbstate_t>::value), "");
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user