本文整理汇总了C++中SV::find方法的典型用法代码示例。如果您正苦于以下问题:C++ SV::find方法的具体用法?C++ SV::find怎么用?C++ SV::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SV
的用法示例。
在下文中一共展示了SV::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
{
typedef std::experimental::string_view S;
test0<S>();
test1<S>();
test2<S>();
test3<S>();
}
#if TEST_STD_VER > 11
{
typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
constexpr SV sv1;
constexpr SV sv2 { "abcde", 5 };
static_assert (sv1.find( "", 0, 0 ) == 0, "" );
static_assert (sv1.find( "abcde", 0, 0 ) == 0, "" );
static_assert (sv1.find( "abcde", 0, 1 ) == SV::npos, "" );
static_assert (sv2.find( "", 0, 0 ) == 0, "" );
static_assert (sv2.find( "abcde", 0, 0 ) == 0, "" );
static_assert (sv2.find( "abcde", 0, 1 ) == 0, "" );
}
#endif
}
示例2: main
int main()
{
{
typedef std::string_view S;
test(S(""), 'c', 0, S::npos);
test(S(""), 'c', 1, S::npos);
test(S("abcde"), 'c', 0, 2);
test(S("abcde"), 'c', 1, 2);
test(S("abcde"), 'c', 2, 2);
test(S("abcde"), 'c', 4, S::npos);
test(S("abcde"), 'c', 5, S::npos);
test(S("abcde"), 'c', 6, S::npos);
test(S("abcdeabcde"), 'c', 0, 2);
test(S("abcdeabcde"), 'c', 1, 2);
test(S("abcdeabcde"), 'c', 5, 7);
test(S("abcdeabcde"), 'c', 9, S::npos);
test(S("abcdeabcde"), 'c', 10, S::npos);
test(S("abcdeabcde"), 'c', 11, S::npos);
test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2);
test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2);
test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12);
test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos);
test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos);
test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos);
test(S(""), 'c', S::npos);
test(S("abcde"), 'c', 2);
test(S("abcdeabcde"), 'c', 2);
test(S("abcdeabcdeabcdeabcde"), 'c', 2);
}
#if _LIBCPP_STD_VER > 11
{
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
constexpr SV sv1;
constexpr SV sv2 { "abcde", 5 };
static_assert (sv1.find( 'c', 0 ) == SV::npos, "" );
static_assert (sv1.find( 'c', 1 ) == SV::npos, "" );
static_assert (sv2.find( 'c', 0 ) == 2, "" );
static_assert (sv2.find( 'c', 1 ) == 2, "" );
static_assert (sv2.find( 'c', 2 ) == 2, "" );
static_assert (sv2.find( 'c', 3 ) == SV::npos, "" );
static_assert (sv2.find( 'c', 4 ) == SV::npos, "" );
}
#endif
}
示例3: main
int main()
{
{
typedef std::string_view S;
test0<S>();
test1<S>();
}
#if _LIBCPP_STD_VER > 11
{
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
constexpr SV sv1;
constexpr SV sv2 { "abcde", 5 };
static_assert (sv1.find(sv1) == 0, "" );
static_assert (sv1.find(sv2) == SV::npos, "" );
static_assert (sv2.find(sv1) == 0, "" );
static_assert (sv2.find(sv2) == 0, "" );
static_assert (sv2.find(sv2, 1 ) == SV::npos, "" );
}
#endif
}