@@ -34,17 +34,16 @@ struct Test {
3434 typename std::basic_string_view<CharT>::size_type, typename std::basic_string_view<CharT>::size_type) const ;
3535};
3636
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) {
4039 std::basic_string_view<CharT> sv1;
4140#ifdef TEST_HAS_NO_EXCEPTIONS
4241 if (pos > sv.size ())
4342 return ; // would throw if exceptions were enabled
44- sv1 = (sv.*testSub )(pos, n);
43+ sv1 = (sv.*TestSub )(pos, n);
4544#else
4645 try {
47- sv1 = (sv.*testSub )(pos, n);
46+ sv1 = (sv.*TestSub )(pos, n);
4847 assert (pos <= sv.size ());
4948 } catch (const std::out_of_range&) {
5049 assert (pos > sv.size ());
@@ -57,31 +56,31 @@ void testDetail(std::basic_string_view<CharT> sv, typename Test<CharT>::Sub test
5756 assert (sv[pos + i] == sv1[i]);
5857}
5958
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);
6662
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 );
6867
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 );
7269
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);
7677}
7778
7879template <typename CharT>
7980void 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);
8382#if TEST_STD_VER >= 26
84- testCases (sv , &std::basic_string_view<CharT>::subview);
83+ testCases<CharT , &std::basic_string_view<CharT>::subview>(s );
8584#endif // TEST_STD_VER >= 26
8685}
8786
0 commit comments