@@ -34,17 +34,16 @@ struct Test {
34
34
typename std::basic_string_view<CharT>::size_type, typename std::basic_string_view<CharT>::size_type) const ;
35
35
};
36
36
37
- template <typename CharT>
38
- void testDetail (std::basic_string_view<CharT> sv, typename Test<CharT>::Sub testSub, std::size_t n, size_t pos) {
39
- (void )testSub; // Avoid unused parameter warning
37
+ template <typename CharT, typename Test<CharT>::Sub TestSub>
38
+ void testDetail (std::basic_string_view<CharT> sv, std::size_t n, size_t pos) {
40
39
std::basic_string_view<CharT> sv1;
41
40
#ifdef TEST_HAS_NO_EXCEPTIONS
42
41
if (pos > sv.size ())
43
42
return ; // would throw if exceptions were enabled
44
- sv1 = (sv.*testSub )(pos, n);
43
+ sv1 = (sv.*TestSub )(pos, n);
45
44
#else
46
45
try {
47
- sv1 = (sv.*testSub )(pos, n);
46
+ sv1 = (sv.*TestSub )(pos, n);
48
47
assert (pos <= sv.size ());
49
48
} catch (const std::out_of_range&) {
50
49
assert (pos > sv.size ());
@@ -57,31 +56,31 @@ void testDetail(std::basic_string_view<CharT> sv, typename Test<CharT>::Sub test
57
56
assert (sv[pos + i] == sv1[i]);
58
57
}
59
58
60
- template <typename CharT>
61
- void testCases (std::basic_string_view<CharT> sv, typename Test<CharT>::Sub testSub) {
62
- testDetail (sv, testSub, 0 , 0 );
63
- testDetail (sv, testSub, 1 , 0 );
64
- testDetail (sv, testSub, 20 , 0 );
65
- testDetail (sv, testSub, sv.size (), 0 );
59
+ template <typename CharT, typename Test<CharT>::Sub TestSub>
60
+ void testCases (const CharT* s) {
61
+ std::basic_string_view<CharT> sv (s);
66
62
67
- testDetail (sv, testSub, 100 , 3 );
63
+ testDetail<CharT, TestSub>(sv, 0 , 0 );
64
+ testDetail<CharT, TestSub>(sv, 1 , 0 );
65
+ testDetail<CharT, TestSub>(sv, 20 , 0 );
66
+ testDetail<CharT, TestSub>(sv, sv.size (), 0 );
68
67
69
- testDetail (sv, testSub, 0 , std::basic_string_view<CharT>::npos);
70
- testDetail (sv, testSub, 2 , std::basic_string_view<CharT>::npos);
71
- testDetail (sv, testSub, sv.size (), std::basic_string_view<CharT>::npos);
68
+ testDetail<CharT, TestSub>(sv, 100 , 3 );
72
69
73
- testDetail (sv, testSub, sv.size () + 1 , 0 );
74
- testDetail (sv, testSub, sv.size () + 1 , 1 );
75
- testDetail (sv, testSub, sv.size () + 1 , std::basic_string_view<CharT>::npos);
70
+ testDetail<CharT, TestSub>(sv, 0 , std::basic_string_view<CharT>::npos);
71
+ testDetail<CharT, TestSub>(sv, 2 , std::basic_string_view<CharT>::npos);
72
+ testDetail<CharT, TestSub>(sv, sv.size (), std::basic_string_view<CharT>::npos);
73
+
74
+ testDetail<CharT, TestSub>(sv, sv.size () + 1 , 0 );
75
+ testDetail<CharT, TestSub>(sv, sv.size () + 1 , 1 );
76
+ testDetail<CharT, TestSub>(sv, sv.size () + 1 , std::basic_string_view<CharT>::npos);
76
77
}
77
78
78
79
template <typename CharT>
79
80
void testSubs (const CharT* s) {
80
- std::basic_string_view<CharT> sv (s);
81
-
82
- testCases (sv, &std::basic_string_view<CharT>::substr);
81
+ testCases<CharT, &std::basic_string_view<CharT>::substr>(s);
83
82
#if TEST_STD_VER >= 26
84
- testCases (sv , &std::basic_string_view<CharT>::subview);
83
+ testCases<CharT , &std::basic_string_view<CharT>::subview>(s );
85
84
#endif // TEST_STD_VER >= 26
86
85
}
87
86
0 commit comments