summaryrefslogtreecommitdiffhomepage
path: root/src/test-helper.h
blob: 676af737b3e1cd9e4a5d3ec637bdbbe409199bc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include <unicode.h>

#include <string>

// output operators must be in same namespace as the type itself
namespace std {

#ifdef __cpp_char8_t
 std::ostream& operator<<(std::ostream& os, std::basic_string<utf8_t> const& s);
#endif

 std::ostream& operator<<(std::ostream& os, std::basic_string<char16_t> const& s);
 std::ostream& operator<<(std::ostream& os, std::basic_string<char32_t> const& s);

#ifdef __cpp_char8_t
 std::ostream& operator<<(std::ostream& os, utf8_t const& c);
#endif
 std::ostream& operator<<(std::ostream& os, char16_t const& c);
 std::ostream& operator<<(std::ostream& os, char32_t const& c);

} // namespace std

template<typename From, typename To>
std::basic_string<To> std_convert(const std::basic_string<From>& s);

template<>
std::basic_string<utf8_t> std_convert<utf8_t, utf8_t>(const std::basic_string<utf8_t>& s);
template<>
std::basic_string<char16_t> std_convert<utf8_t, char16_t>(const std::basic_string<utf8_t>& s);
template<>
std::basic_string<char32_t> std_convert<utf8_t, char32_t>(const std::basic_string<utf8_t>& s);
template<>
std::basic_string<utf8_t> std_convert<char16_t, utf8_t>(const std::basic_string<char16_t>& s);
template<>
std::basic_string<char16_t> std_convert<char16_t, char16_t>(const std::basic_string<char16_t>& s);
template<>
std::basic_string<char32_t> std_convert<char16_t, char32_t>(const std::basic_string<char16_t>& s);
template<>
std::basic_string<utf8_t> std_convert<char32_t, utf8_t>(const std::basic_string<char32_t>& s);
template<>
std::basic_string<char16_t> std_convert<char32_t, char16_t>(const std::basic_string<char32_t>& s);
template<>
std::basic_string<char32_t> std_convert<char32_t, char32_t>(const std::basic_string<char32_t>& s);