Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits>
// constexpr bool operator==(basic_string_view<charT,traits> lhs, const charT* rhs);
// template<class charT, class traits>
// constexpr bool operator==(const charT* lhs, basic_string_view<charT,traits> rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(S lhs, const typename S::value_type* rhs, bool x)
{
assert((lhs == rhs) == x);
assert((rhs == lhs) == x);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), "", true);
test(S(""), "abcde", false);
test(S(""), "abcdefghij", false);
test(S(""), "abcdefghijklmnopqrst", false);
test(S("abcde"), "", false);
test(S("abcde"), "abcde", true);
test(S("abcde"), "abcdefghij", false);
test(S("abcde"), "abcdefghijklmnopqrst", false);
test(S("abcdefghij"), "", false);
test(S("abcdefghij"), "abcde", false);
test(S("abcdefghij"), "abcdefghij", true);
test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
test(S("abcdefghijklmnopqrst"), "", false);
test(S("abcdefghijklmnopqrst"), "abcde", false);
test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
}

#if _LIBCPP_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 == "", "" );
static_assert ( "" == sv1, "" );
static_assert (!(sv1 == "abcde"), "" );
static_assert (!("abcde" == sv1), "" );

static_assert ( sv2 == "abcde", "" );
static_assert ( "abcde" == sv2, "" );
static_assert (!(sv2 == "abcde0"), "" );
static_assert (!("abcde0" == sv2), "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits, class Allocator>
// bool operator==(const charT* lhs, const basic_string<charT,traits> rhs);
// template<class charT, class traits, class Allocator>
// bool operator==(const basic_string_view<charT,traits> lhs, const CharT* rhs);

#include <experimental/string_view>
#include <cassert>

#if _LIBCPP_STD_VER > 11

template <class S>
void
test(const std::string &lhs, S rhs, bool x)
{
assert((lhs == rhs) == x);
assert((rhs == lhs) == x);
}

int main()
{
{
typedef std::experimental::string_view S;
test("", S(""), true);
test("", S("abcde"), false);
test("", S("abcdefghij"), false);
test("", S("abcdefghijklmnopqrst"), false);
test("abcde", S(""), false);
test("abcde", S("abcde"), true);
test("abcde", S("abcdefghij"), false);
test("abcde", S("abcdefghijklmnopqrst"), false);
test("abcdefghij", S(""), false);
test("abcdefghij", S("abcde"), false);
test("abcdefghij", S("abcdefghij"), true);
test("abcdefghij", S("abcdefghijklmnopqrst"), false);
test("abcdefghijklmnopqrst", S(""), false);
test("abcdefghijklmnopqrst", S("abcde"), false);
test("abcdefghijklmnopqrst", S("abcdefghij"), false);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
}
}
#else
int main () {}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string_view>

// template<class charT, class traits, class Allocator>
// constexpr bool operator==(const basic_string_view<charT,traits> lhs,
// const basic_string_view<charT,traits> rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(S lhs, S rhs, bool x)
{
assert((lhs == rhs) == x);
assert((rhs == lhs) == x);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), S(""), true);
test(S(""), S("abcde"), false);
test(S(""), S("abcdefghij"), false);
test(S(""), S("abcdefghijklmnopqrst"), false);
test(S("abcde"), S(""), false);
test(S("abcde"), S("abcde"), true);
test(S("abcde"), S("abcdefghij"), false);
test(S("abcde"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), S(""), false);
test(S("abcdefghij"), S("abcde"), false);
test(S("abcdefghij"), S("abcdefghij"), true);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), S(""), false);
test(S("abcdefghijklmnopqrst"), S("abcde"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}

#if _LIBCPP_STD_VER > 11
{
typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
constexpr SV sv1;
constexpr SV sv2;
constexpr SV sv3 { "abcde", 5 };
static_assert ( sv1 == sv2, "" );
static_assert (!(sv1 == sv3), "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits, class Allocator>
// constexpr bool operator>=(const charT* lhs, basic_string_wiew<charT,traits> rhs);
// template<class charT, class traits, class Allocator>
// constexpr bool operator>=(basic_string_wiew<charT,traits> lhs, const charT* rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
{
assert((lhs >= rhs) == x);
assert((rhs >= lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test("", S(""), true, true);
test("", S("abcde"), false, true);
test("", S("abcdefghij"), false, true);
test("", S("abcdefghijklmnopqrst"), false, true);
test("abcde", S(""), true, false);
test("abcde", S("abcde"), true, true);
test("abcde", S("abcdefghij"), false, true);
test("abcde", S("abcdefghijklmnopqrst"), false, true);
test("abcdefghij", S(""), true, false);
test("abcdefghij", S("abcde"), true, false);
test("abcdefghij", S("abcdefghij"), true, true);
test("abcdefghij", S("abcdefghijklmnopqrst"), false, true);
test("abcdefghijklmnopqrst", S(""), true, false);
test("abcdefghijklmnopqrst", S("abcde"), true, false);
test("abcdefghijklmnopqrst", S("abcdefghij"), true, false);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true, true);
}

#if _LIBCPP_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 >= "", "" );
static_assert ( "" >= sv1, "" );
static_assert (!(sv1 >= "abcde"), "" );
static_assert ( "abcde" >= sv1, "" );

static_assert ( sv2 >= "", "" );
static_assert (!("" >= sv2), "" );
static_assert ( sv2 >= "abcde", "" );
static_assert ( "abcde" >= sv2, "" );
static_assert (!(sv2 >= "abcde0"), "" );
static_assert ( "abcde0" >= sv2, "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits, class Allocator>
// bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
// basic_string_view<charT,traits> rhs);
// bool operator>=(basic_string_view<charT,traits> lhs,
// const basic_string<charT,traits,Allocator>& rhs);

#include <experimental/string_view>
#include <cassert>

template <class S>
void
test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
{
assert((lhs >= rhs) == x);
assert((rhs >= lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), "", true, true);
test(S(""), "abcde", false, true);
test(S(""), "abcdefghij", false, true);
test(S(""), "abcdefghijklmnopqrst", false, true);
test(S("abcde"), "", true, false);
test(S("abcde"), "abcde", true, true);
test(S("abcde"), "abcdefghij", false, true);
test(S("abcde"), "abcdefghijklmnopqrst", false, true);
test(S("abcdefghij"), "", true, false);
test(S("abcdefghij"), "abcde", true, false);
test(S("abcdefghij"), "abcdefghij", true, true);
test(S("abcdefghij"), "abcdefghijklmnopqrst", false, true);
test(S("abcdefghijklmnopqrst"), "", true, false);
test(S("abcdefghijklmnopqrst"), "abcde", true, false);
test(S("abcdefghijklmnopqrst"), "abcdefghij", true, false);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits>
// constexpr bool operator>=(basic_string_view<charT,traits> lhs,
// basic_string_view<charT,traits> rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const S& lhs, const S& rhs, bool x, bool y)
{
assert((lhs >= rhs) == x);
assert((rhs >= lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), S(""), true, true);
test(S(""), S("abcde"), false, true);
test(S(""), S("abcdefghij"), false, true);
test(S(""), S("abcdefghijklmnopqrst"), false, true);
test(S("abcde"), S(""), true, false);
test(S("abcde"), S("abcde"), true, true);
test(S("abcde"), S("abcdefghij"), false, true);
test(S("abcde"), S("abcdefghijklmnopqrst"), false, true);
test(S("abcdefghij"), S(""), true, false);
test(S("abcdefghij"), S("abcde"), true, false);
test(S("abcdefghij"), S("abcdefghij"), true, true);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false, true);
test(S("abcdefghijklmnopqrst"), S(""), true, false);
test(S("abcdefghijklmnopqrst"), S("abcde"), true, false);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true, false);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true, true);
}

#if _LIBCPP_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 >= sv1, "" );
static_assert ( sv2 >= sv2, "" );

static_assert (!(sv1 >= sv2), "" );
static_assert ( sv2 >= sv1, "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// constexpr template<class charT, class traits, class Allocator>
// bool operator>(const charT* lhs, basic_string_wiew<charT,traits> rhs);
// constexpr template<class charT, class traits, class Allocator>
// bool operator>(basic_string_wiew<charT,traits> lhs, const charT* rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
{
assert((lhs > rhs) == x);
assert((rhs > lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test("", S(""), false, false);
test("", S("abcde"), false, true);
test("", S("abcdefghij"), false, true);
test("", S("abcdefghijklmnopqrst"), false, true);
test("abcde", S(""), true, false);
test("abcde", S("abcde"), false, false);
test("abcde", S("abcdefghij"), false, true);
test("abcde", S("abcdefghijklmnopqrst"), false, true);
test("abcdefghij", S(""), true, false);
test("abcdefghij", S("abcde"), true, false);
test("abcdefghij", S("abcdefghij"), false, false);
test("abcdefghij", S("abcdefghijklmnopqrst"), false, true);
test("abcdefghijklmnopqrst", S(""), true, false);
test("abcdefghijklmnopqrst", S("abcde"), true, false);
test("abcdefghijklmnopqrst", S("abcdefghij"), true, false);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false, false);
}

#if _LIBCPP_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 > ""), "" );
static_assert (!("" > sv1), "" );
static_assert (!(sv1 > "abcde"), "" );
static_assert ( "abcde" > sv1, "" );

static_assert ( sv2 > "", "" );
static_assert (!("" > sv2), "" );
static_assert (!(sv2 > "abcde"), "" );
static_assert (!("abcde" > sv2), "" );
static_assert (!(sv2 > "abcde0"), "" );
static_assert ( "abcde0" > sv2, "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits, class Allocator>
// bool operator>(const basic_string<charT,traits,Allocator>& lhs,
// basic_string_view<charT,traits> rhs);
// bool operator>(basic_string_view<charT,traits> lhs,
// const basic_string<charT,traits,Allocator>& rhs);

#include <experimental/string_view>
#include <cassert>

template <class S>
void
test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
{
assert((lhs > rhs) == x);
assert((rhs > lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), "", false, false);
test(S(""), "abcde", false, true);
test(S(""), "abcdefghij", false, true);
test(S(""), "abcdefghijklmnopqrst", false, true);
test(S("abcde"), "", true, false);
test(S("abcde"), "abcde", false, false);
test(S("abcde"), "abcdefghij", false, true);
test(S("abcde"), "abcdefghijklmnopqrst", false, true);
test(S("abcdefghij"), "", true, false);
test(S("abcdefghij"), "abcde", true, false);
test(S("abcdefghij"), "abcdefghij", false, false);
test(S("abcdefghij"), "abcdefghijklmnopqrst", false, true);
test(S("abcdefghijklmnopqrst"), "", true, false);
test(S("abcdefghijklmnopqrst"), "abcde", true, false);
test(S("abcdefghijklmnopqrst"), "abcdefghij", true, false);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits>
// constexpr bool operator>(basic_string_view<charT,traits> lhs,
// basic_string_view<charT,traits> rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const S& lhs, const S& rhs, bool x, bool y)
{
assert((lhs > rhs) == x);
assert((rhs > lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), S(""), false, false);
test(S(""), S("abcde"), false, true);
test(S(""), S("abcdefghij"), false, true);
test(S(""), S("abcdefghijklmnopqrst"), false, true);
test(S("abcde"), S(""), true, false);
test(S("abcde"), S("abcde"), false, false);
test(S("abcde"), S("abcdefghij"), false, true);
test(S("abcde"), S("abcdefghijklmnopqrst"), false, true);
test(S("abcdefghij"), S(""), true, false);
test(S("abcdefghij"), S("abcde"), true, false);
test(S("abcdefghij"), S("abcdefghij"), false, false);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false, true);
test(S("abcdefghijklmnopqrst"), S(""), true, false);
test(S("abcdefghijklmnopqrst"), S("abcde"), true, false);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true, false);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false, false);
}

#if _LIBCPP_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 > sv1), "" );
static_assert (!(sv2 > sv2), "" );

static_assert (!(sv1 > sv2), "" );
static_assert ( sv2 > sv1, "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits, class Allocator>
// constexpr bool operator<=(const charT* lhs, basic_string_wiew<charT,traits> rhs);
// template<class charT, class traits, class Allocator>
// constexpr bool operator<=(basic_string_wiew<charT,traits> lhs, const charT* rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
{
assert((lhs <= rhs) == x);
assert((rhs <= lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test("", S(""), true, true);
test("", S("abcde"), true, false);
test("", S("abcdefghij"), true, false);
test("", S("abcdefghijklmnopqrst"), true, false);
test("abcde", S(""), false, true);
test("abcde", S("abcde"), true, true);
test("abcde", S("abcdefghij"), true, false);
test("abcde", S("abcdefghijklmnopqrst"), true, false);
test("abcdefghij", S(""), false, true);
test("abcdefghij", S("abcde"), false, true);
test("abcdefghij", S("abcdefghij"), true, true);
test("abcdefghij", S("abcdefghijklmnopqrst"), true, false);
test("abcdefghijklmnopqrst", S(""), false, true);
test("abcdefghijklmnopqrst", S("abcde"), false, true);
test("abcdefghijklmnopqrst", S("abcdefghij"), false, true);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true, true);
}

#if _LIBCPP_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 <= "", "" );
static_assert ( "" <= sv1, "" );
static_assert ( sv1 <= "abcde", "" );
static_assert (!("abcde" <= sv1), "" );

static_assert (!(sv2 <= ""), "" );
static_assert ( "" <= sv2, "" );
static_assert ( sv2 <= "abcde", "" );
static_assert ( "abcde" <= sv2, "" );
static_assert ( sv2 <= "abcde0", "" );
static_assert (!("abcde0" <= sv2), "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits, class Allocator>
// bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
// basic_string_view<charT,traits> rhs);
// bool operator<=(basic_string_view<charT,traits> lhs,
// const basic_string<charT,traits,Allocator>& rhs);

#include <experimental/string_view>
#include <cassert>

template <class S>
void
test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
{
assert((lhs <= rhs) == x);
assert((rhs <= lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), "", true, true);
test(S(""), "abcde", true, false);
test(S(""), "abcdefghij", true, false);
test(S(""), "abcdefghijklmnopqrst", true, false);
test(S("abcde"), "", false, true);
test(S("abcde"), "abcde", true, true);
test(S("abcde"), "abcdefghij", true, false);
test(S("abcde"), "abcdefghijklmnopqrst", true, false);
test(S("abcdefghij"), "", false, true);
test(S("abcdefghij"), "abcde", false, true);
test(S("abcdefghij"), "abcdefghij", true, true);
test(S("abcdefghij"), "abcdefghijklmnopqrst", true, false);
test(S("abcdefghijklmnopqrst"), "", false, true);
test(S("abcdefghijklmnopqrst"), "abcde", false, true);
test(S("abcdefghijklmnopqrst"), "abcdefghij", false, true);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits>
// constexpr bool operator<=(basic_string_view<charT,traits> lhs,
// basic_string_view<charT,traits> rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const S& lhs, const S& rhs, bool x, bool y)
{
assert((lhs <= rhs) == x);
assert((rhs <= lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), S(""), true, true);
test(S(""), S("abcde"), true, false);
test(S(""), S("abcdefghij"), true, false);
test(S(""), S("abcdefghijklmnopqrst"), true, false);
test(S("abcde"), S(""), false, true);
test(S("abcde"), S("abcde"), true, true);
test(S("abcde"), S("abcdefghij"), true, false);
test(S("abcde"), S("abcdefghijklmnopqrst"), true, false);
test(S("abcdefghij"), S(""), false, true);
test(S("abcdefghij"), S("abcde"), false, true);
test(S("abcdefghij"), S("abcdefghij"), true, true);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true, false);
test(S("abcdefghijklmnopqrst"), S(""), false, true);
test(S("abcdefghijklmnopqrst"), S("abcde"), false, true);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false, true);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true, true);
}

#if _LIBCPP_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 <= sv1, "" );
static_assert ( sv2 <= sv2, "" );

static_assert ( sv1 <= sv2, "" );
static_assert (!(sv2 <= sv1), "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits, class Allocator>
// constexpr bool operator<(const charT* lhs, basic_string_wiew<charT,traits> rhs);
// template<class charT, class traits, class Allocator>
// constexpr bool operator<(basic_string_wiew<charT,traits> lhs, const charT* rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
{
assert((lhs < rhs) == x);
assert((rhs < lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test("", S(""), false, false);
test("", S("abcde"), true, false);
test("", S("abcdefghij"), true, false);
test("", S("abcdefghijklmnopqrst"), true, false);
test("abcde", S(""), false, true);
test("abcde", S("abcde"), false, false);
test("abcde", S("abcdefghij"), true, false);
test("abcde", S("abcdefghijklmnopqrst"), true, false);
test("abcdefghij", S(""), false, true);
test("abcdefghij", S("abcde"), false, true);
test("abcdefghij", S("abcdefghij"), false, false);
test("abcdefghij", S("abcdefghijklmnopqrst"), true, false);
test("abcdefghijklmnopqrst", S(""), false, true);
test("abcdefghijklmnopqrst", S("abcde"), false, true);
test("abcdefghijklmnopqrst", S("abcdefghij"), false, true);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false, false);
}

#if _LIBCPP_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 < ""), "" );
static_assert (!("" < sv1), "" );
static_assert ( sv1 < "abcde", "" );
static_assert (!("abcde" < sv1), "" );

static_assert (!(sv2 < ""), "" );
static_assert ( "" < sv2, "" );
static_assert (!(sv2 < "abcde"), "" );
static_assert (!("abcde" < sv2), "" );
static_assert ( sv2 < "abcde0", "" );
static_assert (!("abcde0" < sv2), "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits, class Allocator>
// bool operator<(const basic_string<charT,traits,Allocator>& lhs,
// basic_string_view<charT,traits> rhs);
// bool operator<(basic_string_view<charT,traits> lhs,
// const basic_string<charT,traits,Allocator>& rhs);

#include <experimental/string_view>
#include <cassert>

template <class S>
void
test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
{
assert((lhs < rhs) == x);
assert((rhs < lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), "", false, false);
test(S(""), "abcde", true, false);
test(S(""), "abcdefghij", true, false);
test(S(""), "abcdefghijklmnopqrst", true, false);
test(S("abcde"), "", false, true);
test(S("abcde"), "abcde", false, false);
test(S("abcde"), "abcdefghij", true, false);
test(S("abcde"), "abcdefghijklmnopqrst", true, false);
test(S("abcdefghij"), "", false, true);
test(S("abcdefghij"), "abcde", false, true);
test(S("abcdefghij"), "abcdefghij", false, false);
test(S("abcdefghij"), "abcdefghijklmnopqrst", true, false);
test(S("abcdefghijklmnopqrst"), "", false, true);
test(S("abcdefghijklmnopqrst"), "abcde", false, true);
test(S("abcdefghijklmnopqrst"), "abcdefghij", false, true);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits>
// constexpr bool operator<(basic_string_view<charT,traits> lhs,
// basic_string_view<charT,traits> rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const S& lhs, const S& rhs, bool x, bool y)
{
assert((lhs < rhs) == x);
assert((rhs < lhs) == y);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), S(""), false, false);
test(S(""), S("abcde"), true, false);
test(S(""), S("abcdefghij"), true, false);
test(S(""), S("abcdefghijklmnopqrst"), true, false);
test(S("abcde"), S(""), false, true);
test(S("abcde"), S("abcde"), false, false);
test(S("abcde"), S("abcdefghij"), true, false);
test(S("abcde"), S("abcdefghijklmnopqrst"), true, false);
test(S("abcdefghij"), S(""), false, true);
test(S("abcdefghij"), S("abcde"), false, true);
test(S("abcdefghij"), S("abcdefghij"), false, false);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true, false);
test(S("abcdefghijklmnopqrst"), S(""), false, true);
test(S("abcdefghijklmnopqrst"), S("abcde"), false, true);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false, true);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false, false);
}

#if _LIBCPP_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 < sv1), "" );
static_assert (!(sv2 < sv2), "" );

static_assert ( sv1 < sv2, "" );
static_assert (!(sv2 < sv1), "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits>
// constexpr bool operator!=(basic_string_view<charT,traits> lhs, const charT* rhs);
// template<class charT, class traits>
// constexpr bool operator!=(const charT* lhs, basic_string_view<charT,traits> rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(S lhs, const typename S::value_type* rhs, bool x)
{
assert((lhs != rhs) == x);
assert((rhs != lhs) == x);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), "", false);
test(S(""), "abcde", true);
test(S(""), "abcdefghij", true);
test(S(""), "abcdefghijklmnopqrst", true);
test(S("abcde"), "", true);
test(S("abcde"), "abcde", false);
test(S("abcde"), "abcdefghij", true);
test(S("abcde"), "abcdefghijklmnopqrst", true);
test(S("abcdefghij"), "", true);
test(S("abcdefghij"), "abcde", true);
test(S("abcdefghij"), "abcdefghij", false);
test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
test(S("abcdefghijklmnopqrst"), "", true);
test(S("abcdefghijklmnopqrst"), "abcde", true);
test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
}

#if _LIBCPP_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 != ""), "" );
static_assert (!("" != sv1), "" );
static_assert ( sv1 != "abcde", "" );
static_assert ( "abcde" != sv1, "" );

static_assert (!(sv2 != "abcde"), "" );
static_assert (!("abcde" != sv2), "" );
static_assert ( sv2 != "abcde0", "" );
static_assert ( "abcde0" != sv2, "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// template<class charT, class traits, class Allocator>
// bool operator!=(const basic_string<charT, traits, Allocator> &lhs, basic_string_view<charT,traits> rhs);
// template<class charT, class traits, class Allocator>
// bool operator!=(basic_string_view<charT,traits> lhs, const basic_string<charT, traits, Allocator> &rhs);

#include <experimental/string_view>
#include <cassert>

template <class S>
void
test(const std::string &lhs, S rhs, bool x)
{
assert((lhs != rhs) == x);
assert((rhs != lhs) == x);
}

int main()
{
{
typedef std::experimental::string_view S;
test("", S(""), false);
test("", S("abcde"), true);
test("", S("abcdefghij"), true);
test("", S("abcdefghijklmnopqrst"), true);
test("abcde", S(""), true);
test("abcde", S("abcde"), false);
test("abcde", S("abcdefghij"), true);
test("abcde", S("abcdefghijklmnopqrst"), true);
test("abcdefghij", S(""), true);
test("abcdefghij", S("abcde"), true);
test("abcdefghij", S("abcdefghij"), false);
test("abcdefghij", S("abcdefghijklmnopqrst"), true);
test("abcdefghijklmnopqrst", S(""), true);
test("abcdefghijklmnopqrst", S("abcde"), true);
test("abcdefghijklmnopqrst", S("abcdefghij"), true);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string_view>

// template<class charT, class traits, class Allocator>
// constexpr bool operator!=(const basic_string_view<charT,traits> lhs,
// const basic_string_view<charT,traits> rhs);

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(S lhs, S rhs, bool x)
{
assert((lhs != rhs) == x);
assert((rhs != lhs) == x);
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), S(""), false);
test(S(""), S("abcde"), true);
test(S(""), S("abcdefghij"), true);
test(S(""), S("abcdefghijklmnopqrst"), true);
test(S("abcde"), S(""), true);
test(S("abcde"), S("abcde"), false);
test(S("abcde"), S("abcdefghij"), true);
test(S("abcde"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), S(""), true);
test(S("abcdefghij"), S("abcde"), true);
test(S("abcdefghij"), S("abcdefghij"), false);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), S(""), true);
test(S("abcdefghijklmnopqrst"), S("abcde"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}

#if _LIBCPP_STD_VER > 11
{
typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
constexpr SV sv1;
constexpr SV sv2;
constexpr SV sv3 { "abcde", 5 };
static_assert (!( sv1 != sv2), "" );
static_assert ( sv1 != sv3, "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//


// <string_view>

// constexpr basic_string_view () noexcept;

#include <experimental/string_view>
#include <cassert>

template<typename T>
void test () {
#if _LIBCPP_STD_VER > 11
{
constexpr T sv1;
static_assert ( sv1.size() == 0, "" );
static_assert ( sv1.empty(), "");
}
#endif

{
T sv1;
assert ( sv1.size() == 0 );
assert ( sv1.empty());
}
}

int main () {
using string_view = std::experimental::string_view;
using u16string_view = std::experimental::u16string_view;
using u32string_view = std::experimental::u32string_view;
using wstring_view = std::experimental::wstring_view;

test<string_view> ();
test<u16string_view> ();
test<u32string_view> ();
test<wstring_view> ();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//


// <string_view>

// constexpr basic_string_view(const _CharT* _s)
// : __data (_s), __size(_Traits::length(_s)) {}


#include <experimental/string_view>
#include <string>
#include <cassert>

#include "constexpr_char_traits.hpp"

template<typename CharT>
size_t StrLen ( const CharT *s ) {
size_t retVal = 0;
while ( *s != 0 ) { ++retVal; ++s; }
return retVal;
}

template<typename CharT>
void test ( const CharT *s ) {
std::experimental::basic_string_view<CharT> sv1 ( s );
assert ( sv1.size() == StrLen( s ));
assert ( sv1.data() == s );
}


int main () {

test ( "QBCDE" );
test ( "A" );
test ( "" );

test ( L"QBCDE" );
test ( L"A" );
test ( L"" );

#if __cplusplus >= 201103L
test ( u"QBCDE" );
test ( u"A" );
test ( u"" );

test ( U"QBCDE" );
test ( U"A" );
test ( U"" );
#endif

#if _LIBCPP_STD_VER > 11
{
constexpr std::experimental::basic_string_view<char, constexpr_char_traits<char>> sv1 ( "ABCDE" );
static_assert ( sv1.size() == 5, "");
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//


// <string_view>

// constexpr basic_string_view(const _CharT* _s, size_type _len)
// : __data (_s), __size(_len) {}


#include <experimental/string_view>
#include <string>
#include <cassert>

template<typename CharT>
void test ( const CharT *s, size_t sz ) {
{
std::experimental::basic_string_view<CharT> sv1 ( s, sz );
assert ( sv1.size() == sz );
assert ( sv1.data() == s );
}
}

int main () {

test ( "QBCDE", 5 );
test ( "QBCDE", 2 );
test ( "", 0 );
#if _LIBCPP_STD_VER > 11
{
constexpr const char *s = "QBCDE";
constexpr std::experimental::basic_string_view<char> sv1 ( s, 2 );
static_assert ( sv1.size() == 2, "" );
static_assert ( sv1.data() == s, "" );
}
#endif

test ( L"QBCDE", 5 );
test ( L"QBCDE", 2 );
test ( L"", 0 );
#if _LIBCPP_STD_VER > 11
{
constexpr const wchar_t *s = L"QBCDE";
constexpr std::experimental::basic_string_view<wchar_t> sv1 ( s, 2 );
static_assert ( sv1.size() == 2, "" );
static_assert ( sv1.data() == s, "" );
}
#endif

#if __cplusplus >= 201103L
test ( u"QBCDE", 5 );
test ( u"QBCDE", 2 );
test ( u"", 0 );
#if _LIBCPP_STD_VER > 11
{
constexpr const char16_t *s = u"QBCDE";
constexpr std::experimental::basic_string_view<char16_t> sv1 ( s, 2 );
static_assert ( sv1.size() == 2, "" );
static_assert ( sv1.data() == s, "" );
}
#endif

test ( U"QBCDE", 5 );
test ( U"QBCDE", 2 );
test ( U"", 0 );
#if _LIBCPP_STD_VER > 11
{
constexpr const char32_t *s = U"QBCDE";
constexpr std::experimental::basic_string_view<char32_t> sv1 ( s, 2 );
static_assert ( sv1.size() == 2, "" );
static_assert ( sv1.data() == s, "" );
}
#endif
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//


// <string_view>

// template<class Allocator>
// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept


#include <experimental/string_view>
#include <string>
#include <cassert>

struct dummy_char_traits : public std::char_traits<char> {};

template<typename CharT, typename Traits>
void test ( const std::basic_string<CharT, Traits> &str ) {
std::experimental::basic_string_view<CharT, Traits> sv1 ( str );
assert ( sv1.size() == str.size());
assert ( sv1.data() == str.data());
}

int main () {

test ( std::string("QBCDE") );
test ( std::string("") );
test ( std::string() );

test ( std::wstring(L"QBCDE") );
test ( std::wstring(L"") );
test ( std::wstring() );

#if __cplusplus >= 201103L
test ( std::u16string{u"QBCDE"} );
test ( std::u16string{u""} );
test ( std::u16string{} );

test ( std::u32string{U"QBCDE"} );
test ( std::u32string{U""} );
test ( std::u32string{} );
#endif

test ( std::basic_string<char, dummy_char_traits>("QBCDE") );
test ( std::basic_string<char, dummy_char_traits>("") );
test ( std::basic_string<char, dummy_char_traits>() );

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//


// <string_view>

// template<class Allocator>
// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept

#include <experimental/string_view>
#include <string>
#include <cassert>

struct dummy_char_traits : public std::char_traits<char> {};

int main () {
using string_view = std::experimental::basic_string_view<char>;
using string = std:: basic_string <char, dummy_char_traits>;

{
string s{"QBCDE"};
string_view sv1 ( s );
assert ( sv1.size() == s.size());
assert ( sv1.data() == s.data());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//


// <string_view>

// template<class Allocator>
// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept

#include <experimental/string_view>
#include <string>
#include <cassert>

struct dummy_char_traits : public std::char_traits<char> {};

int main () {
using string_view = std::experimental::basic_string_view<char, dummy_char_traits>;
using string = std:: basic_string <char>;

{
string s{"QBCDE"};
string_view sv1 ( s );
assert ( sv1.size() == s.size());
assert ( sv1.data() == s.data());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string_view>

// constexpr size_type find(charT c, size_type pos = 0) const;

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type pos,
typename S::size_type x)
{
assert(s.find(c, pos) == x);
if (x != S::npos)
assert(pos <= x && x + 1 <= s.size());
}

template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type x)
{
assert(s.find(c) == x);
if (x != S::npos)
assert(0 <= x && x + 1 <= s.size());
}

int main()
{
{
typedef std::experimental::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::experimental::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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string_view>

// constexpr size_type find_first_not_of(charT c, size_type pos = 0) const;

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type pos,
typename S::size_type x)
{
assert(s.find_first_not_of(c, pos) == x);
if (x != S::npos)
assert(pos <= x && x < s.size());
}

template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type x)
{
assert(s.find_first_not_of(c) == x);
if (x != S::npos)
assert(x < s.size());
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), 'q', 0, S::npos);
test(S(""), 'q', 1, S::npos);
test(S("kitcj"), 'q', 0, 0);
test(S("qkamf"), 'q', 1, 1);
test(S("nhmko"), 'q', 2, 2);
test(S("tpsaf"), 'q', 4, 4);
test(S("lahfb"), 'q', 5, S::npos);
test(S("irkhs"), 'q', 6, S::npos);
test(S("gmfhdaipsr"), 'q', 0, 0);
test(S("kantesmpgj"), 'q', 1, 1);
test(S("odaftiegpm"), 'q', 5, 5);
test(S("oknlrstdpi"), 'q', 9, 9);
test(S("eolhfgpjqk"), 'q', 10, S::npos);
test(S("pcdrofikas"), 'q', 11, S::npos);
test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0);
test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1);
test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10);
test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19);
test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos);
test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos);

test(S(""), 'q', S::npos);
test(S("q"), 'q', S::npos);
test(S("qqq"), 'q', S::npos);
test(S("csope"), 'q', 0);
test(S("gfsmthlkon"), 'q', 0);
test(S("laenfsbridchgotmkqpj"), 'q', 0);
}

#if _LIBCPP_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_first_not_of( 'q', 0 ) == SV::npos, "" );
static_assert (sv1.find_first_not_of( 'q', 1 ) == SV::npos, "" );
static_assert (sv2.find_first_not_of( 'q', 0 ) == 0, "" );
static_assert (sv2.find_first_not_of( 'q', 1 ) == 1, "" );
static_assert (sv2.find_first_not_of( 'q', 5 ) == SV::npos, "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string_view>

// constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const S& s, const typename S::value_type* str, typename S::size_type pos,
typename S::size_type x)
{
assert(s.find_first_not_of(str, pos) == x);
if (x != S::npos)
assert(pos <= x && x < s.size());
}

template <class S>
void
test(const S& s, const typename S::value_type* str, typename S::size_type x)
{
assert(s.find_first_not_of(str) == x);
if (x != S::npos)
assert(x < s.size());
}

template <class S>
void test0()
{
test(S(""), "", 0, S::npos);
test(S(""), "laenf", 0, S::npos);
test(S(""), "pqlnkmbdjo", 0, S::npos);
test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
test(S(""), "", 1, S::npos);
test(S(""), "bjaht", 1, S::npos);
test(S(""), "hjlcmgpket", 1, S::npos);
test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
test(S("fodgq"), "", 0, 0);
test(S("qanej"), "dfkap", 0, 0);
test(S("clbao"), "ihqrfebgad", 0, 0);
test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
test(S("srdfq"), "", 1, 1);
test(S("oemth"), "ikcrq", 1, 1);
test(S("cdaih"), "dmajblfhsg", 1, 3);
test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
test(S("cshmd"), "", 2, 2);
test(S("lhcdo"), "oebqi", 2, 2);
test(S("qnsoh"), "kojhpmbsfe", 2, S::npos);
test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
test(S("fmtsp"), "", 4, 4);
test(S("khbpm"), "aobjd", 4, 4);
test(S("pbsji"), "pcbahntsje", 4, 4);
test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
test(S("eqmpa"), "", 5, S::npos);
test(S("omigs"), "kocgb", 5, S::npos);
test(S("onmje"), "fbslrjiqkm", 5, S::npos);
test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
test(S("schfa"), "", 6, S::npos);
test(S("igdsc"), "qngpd", 6, S::npos);
test(S("brqgo"), "rodhqklgmb", 6, S::npos);
test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
test(S("hcjitbfapl"), "", 0, 0);
test(S("daiprenocl"), "ashjd", 0, 2);
test(S("litpcfdghe"), "mgojkldsqh", 0, 1);
test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
test(S("qpghtfbaji"), "", 1, 1);
test(S("gfshlcmdjr"), "nadkh", 1, 1);
test(S("nkodajteqp"), "ofdrqmkebl", 1, 4);
test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
test(S("crnklpmegd"), "", 5, 5);
test(S("jsbtafedoc"), "prqgn", 5, 5);
test(S("qnmodrtkeb"), "pejafmnokr", 5, 6);
test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
test(S("lmofqdhpki"), "", 9, 9);
test(S("hnefkqimca"), "rtjpa", 9, S::npos);
test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
test(S("elgofjmbrq"), "", 10, S::npos);
test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
test(S("eqsgalomhb"), "", 11, S::npos);
test(S("akiteljmoh"), "lofbc", 11, S::npos);
test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 1);
test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 3);
test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 11);
test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 13);
test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
test(S("niptglfbosehkamrdqcj"), "", 19, 19);
test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, S::npos);
test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
}

template <class S>
void test1()
{
test(S(""), "", S::npos);
test(S(""), "laenf", S::npos);
test(S(""), "pqlnkmbdjo", S::npos);
test(S(""), "qkamfogpnljdcshbreti", S::npos);
test(S("nhmko"), "", 0);
test(S("lahfb"), "irkhs", 0);
test(S("gmfhd"), "kantesmpgj", 2);
test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
test(S("eolhfgpjqk"), "", 0);
test(S("nbatdlmekr"), "bnrpe", 2);
test(S("jdmciepkaq"), "jtdaefblso", 2);
test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
test(S("gprdcokbnjhlsfmtieqa"), "", 0);
test(S("qjghlnftcaismkropdeb"), "bjaht", 0);
test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 1);
test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
}

int main()
{
{
typedef std::experimental::string_view S;
test0<S>();
test1<S>();
}

#if _LIBCPP_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_first_not_of( "", 0) == SV::npos, "" );
static_assert (sv1.find_first_not_of( "irkhs", 0) == SV::npos, "" );
static_assert (sv2.find_first_not_of( "", 0) == 0, "" );
static_assert (sv2.find_first_not_of( "gfsrt", 0) == 0, "" );
static_assert (sv2.find_first_not_of( "lecar", 0) == 1, "" );
}
#endif
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string_view>

// size_type find_first_not_of(const basic_string& str, size_type pos = 0) const;

#include <experimental/string_view>
#include <cassert>

template <class S>
void
test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
{
assert(s.find_first_not_of(str, pos) == x);
if (x != S::npos)
assert(pos <= x && x < s.size());
}

template <class S>
void
test(const S& s, const S& str, typename S::size_type x)
{
assert(s.find_first_not_of(str) == x);
if (x != S::npos)
assert(x < s.size());
}

template <class S>
void test0()
{
test(S(""), S(""), 0, S::npos);
test(S(""), S("laenf"), 0, S::npos);
test(S(""), S("pqlnkmbdjo"), 0, S::npos);
test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
test(S(""), S(""), 1, S::npos);
test(S(""), S("bjaht"), 1, S::npos);
test(S(""), S("hjlcmgpket"), 1, S::npos);
test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
test(S("fodgq"), S(""), 0, 0);
test(S("qanej"), S("dfkap"), 0, 0);
test(S("clbao"), S("ihqrfebgad"), 0, 0);
test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos);
test(S("srdfq"), S(""), 1, 1);
test(S("oemth"), S("ikcrq"), 1, 1);
test(S("cdaih"), S("dmajblfhsg"), 1, 3);
test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos);
test(S("cshmd"), S(""), 2, 2);
test(S("lhcdo"), S("oebqi"), 2, 2);
test(S("qnsoh"), S("kojhpmbsfe"), 2, S::npos);
test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos);
test(S("fmtsp"), S(""), 4, 4);
test(S("khbpm"), S("aobjd"), 4, 4);
test(S("pbsji"), S("pcbahntsje"), 4, 4);
test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos);
test(S("eqmpa"), S(""), 5, S::npos);
test(S("omigs"), S("kocgb"), 5, S::npos);
test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
test(S("schfa"), S(""), 6, S::npos);
test(S("igdsc"), S("qngpd"), 6, S::npos);
test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
test(S("hcjitbfapl"), S(""), 0, 0);
test(S("daiprenocl"), S("ashjd"), 0, 2);
test(S("litpcfdghe"), S("mgojkldsqh"), 0, 1);
test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos);
test(S("qpghtfbaji"), S(""), 1, 1);
test(S("gfshlcmdjr"), S("nadkh"), 1, 1);
test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 4);
test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos);
test(S("crnklpmegd"), S(""), 5, 5);
test(S("jsbtafedoc"), S("prqgn"), 5, 5);
test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 6);
test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos);
test(S("lmofqdhpki"), S(""), 9, 9);
test(S("hnefkqimca"), S("rtjpa"), 9, S::npos);
test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9);
test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
test(S("elgofjmbrq"), S(""), 10, S::npos);
test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
test(S("eqsgalomhb"), S(""), 11, S::npos);
test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0);
test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0);
test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 1);
test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos);
test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1);
test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1);
test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 3);
test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos);
test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10);
test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 11);
test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 13);
test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos);
test(S("niptglfbosehkamrdqcj"), S(""), 19, 19);
test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19);
test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, S::npos);
test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos);
test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
}

template <class S>
void test1()
{
test(S(""), S(""), S::npos);
test(S(""), S("laenf"), S::npos);
test(S(""), S("pqlnkmbdjo"), S::npos);
test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
test(S("nhmko"), S(""), 0);
test(S("lahfb"), S("irkhs"), 0);
test(S("gmfhd"), S("kantesmpgj"), 2);
test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos);
test(S("eolhfgpjqk"), S(""), 0);
test(S("nbatdlmekr"), S("bnrpe"), 2);
test(S("jdmciepkaq"), S("jtdaefblso"), 2);
test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos);
test(S("gprdcokbnjhlsfmtieqa"), S(""), 0);
test(S("qjghlnftcaismkropdeb"), S("bjaht"), 0);
test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 1);
test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
}

int main()
{
{
typedef std::experimental::string_view S;
test0<S>();
test1<S>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// constexpr size_type find_first_of(charT c, size_type pos = 0) const;

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type pos,
typename S::size_type x)
{
assert(s.find_first_of(c, pos) == x);
if (x != S::npos)
assert(pos <= x && x < s.size());
}

template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type x)
{
assert(s.find_first_of(c) == x);
if (x != S::npos)
assert(x < s.size());
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), 'e', 0, S::npos);
test(S(""), 'e', 1, S::npos);
test(S("kitcj"), 'e', 0, S::npos);
test(S("qkamf"), 'e', 1, S::npos);
test(S("nhmko"), 'e', 2, S::npos);
test(S("tpsaf"), 'e', 4, S::npos);
test(S("lahfb"), 'e', 5, S::npos);
test(S("irkhs"), 'e', 6, S::npos);
test(S("gmfhdaipsr"), 'e', 0, S::npos);
test(S("kantesmpgj"), 'e', 1, 4);
test(S("odaftiegpm"), 'e', 5, 6);
test(S("oknlrstdpi"), 'e', 9, S::npos);
test(S("eolhfgpjqk"), 'e', 10, S::npos);
test(S("pcdrofikas"), 'e', 11, S::npos);
test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7);
test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4);
test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos);
test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos);
test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos);
test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos);

test(S(""), 'e', S::npos);
test(S("csope"), 'e', 4);
test(S("gfsmthlkon"), 'e', S::npos);
test(S("laenfsbridchgotmkqpj"), 'e', 2);
}

#if _LIBCPP_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_first_of( 'e', 0 ) == SV::npos, "" );
static_assert (sv1.find_first_of( 'e', 1 ) == SV::npos, "" );
static_assert (sv2.find_first_of( 'q', 0 ) == SV::npos, "" );
static_assert (sv2.find_first_of( 'e', 1 ) == 4, "" );
static_assert (sv2.find_first_of( 'e', 5 ) == SV::npos, "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const S& s, const typename S::value_type* str, typename S::size_type pos,
typename S::size_type x)
{
assert(s.find_first_of(str, pos) == x);
if (x != S::npos)
assert(pos <= x && x < s.size());
}

template <class S>
void
test(const S& s, const typename S::value_type* str, typename S::size_type x)
{
assert(s.find_first_of(str) == x);
if (x != S::npos)
assert(x < s.size());
}

template <class S>
void test0()
{
test(S(""), "", 0, S::npos);
test(S(""), "laenf", 0, S::npos);
test(S(""), "pqlnkmbdjo", 0, S::npos);
test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
test(S(""), "", 1, S::npos);
test(S(""), "bjaht", 1, S::npos);
test(S(""), "hjlcmgpket", 1, S::npos);
test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
test(S("fodgq"), "", 0, S::npos);
test(S("qanej"), "dfkap", 0, 1);
test(S("clbao"), "ihqrfebgad", 0, 2);
test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
test(S("srdfq"), "", 1, S::npos);
test(S("oemth"), "ikcrq", 1, S::npos);
test(S("cdaih"), "dmajblfhsg", 1, 1);
test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
test(S("cshmd"), "", 2, S::npos);
test(S("lhcdo"), "oebqi", 2, 4);
test(S("qnsoh"), "kojhpmbsfe", 2, 2);
test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
test(S("fmtsp"), "", 4, S::npos);
test(S("khbpm"), "aobjd", 4, S::npos);
test(S("pbsji"), "pcbahntsje", 4, S::npos);
test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
test(S("eqmpa"), "", 5, S::npos);
test(S("omigs"), "kocgb", 5, S::npos);
test(S("onmje"), "fbslrjiqkm", 5, S::npos);
test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
test(S("schfa"), "", 6, S::npos);
test(S("igdsc"), "qngpd", 6, S::npos);
test(S("brqgo"), "rodhqklgmb", 6, S::npos);
test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
test(S("hcjitbfapl"), "", 0, S::npos);
test(S("daiprenocl"), "ashjd", 0, 0);
test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
test(S("qpghtfbaji"), "", 1, S::npos);
test(S("gfshlcmdjr"), "nadkh", 1, 3);
test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
test(S("crnklpmegd"), "", 5, S::npos);
test(S("jsbtafedoc"), "prqgn", 5, S::npos);
test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
test(S("lmofqdhpki"), "", 9, S::npos);
test(S("hnefkqimca"), "rtjpa", 9, 9);
test(S("drtasbgmfp"), "ktsrmnqagd", 9, S::npos);
test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
test(S("elgofjmbrq"), "", 10, S::npos);
test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
test(S("eqsgalomhb"), "", 11, S::npos);
test(S("akiteljmoh"), "lofbc", 11, S::npos);
test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 3);
test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 3);
test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
test(S("copqdhstbingamjfkler"), "djkqc", 19, S::npos);
test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
}

template <class S>
void test1()
{
test(S(""), "", S::npos);
test(S(""), "laenf", S::npos);
test(S(""), "pqlnkmbdjo", S::npos);
test(S(""), "qkamfogpnljdcshbreti", S::npos);
test(S("nhmko"), "", S::npos);
test(S("lahfb"), "irkhs", 2);
test(S("gmfhd"), "kantesmpgj", 0);
test(S("odaft"), "oknlrstdpiqmjbaghcfe", 0);
test(S("eolhfgpjqk"), "", S::npos);
test(S("nbatdlmekr"), "bnrpe", 0);
test(S("jdmciepkaq"), "jtdaefblso", 0);
test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 0);
test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
test(S("qjghlnftcaismkropdeb"), "bjaht", 1);
test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 0);
test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 0);
}

int main()
{
{
typedef std::experimental::string_view S;
test0<S>();
test1<S>();
}

#if _LIBCPP_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_first_of( "", 0) == SV::npos, "" );
static_assert (sv1.find_first_of( "irkhs", 0) == SV::npos, "" );
static_assert (sv2.find_first_of( "", 0) == SV::npos, "" );
static_assert (sv2.find_first_of( "gfsrt", 0) == SV::npos, "" );
static_assert (sv2.find_first_of( "lecar", 0) == 0, "" );
}
#endif
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string>

// size_type find_first_of(const basic_string_view& str, size_type pos = 0) const;

#include <experimental/string_view>
#include <cassert>

template <class S>
void
test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
{
assert(s.find_first_of(str, pos) == x);
if (x != S::npos)
assert(pos <= x && x < s.size());
}

template <class S>
void
test(const S& s, const S& str, typename S::size_type x)
{
assert(s.find_first_of(str) == x);
if (x != S::npos)
assert(x < s.size());
}

template <class S>
void test0()
{
test(S(""), S(""), 0, S::npos);
test(S(""), S("laenf"), 0, S::npos);
test(S(""), S("pqlnkmbdjo"), 0, S::npos);
test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
test(S(""), S(""), 1, S::npos);
test(S(""), S("bjaht"), 1, S::npos);
test(S(""), S("hjlcmgpket"), 1, S::npos);
test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
test(S("fodgq"), S(""), 0, S::npos);
test(S("qanej"), S("dfkap"), 0, 1);
test(S("clbao"), S("ihqrfebgad"), 0, 2);
test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0);
test(S("srdfq"), S(""), 1, S::npos);
test(S("oemth"), S("ikcrq"), 1, S::npos);
test(S("cdaih"), S("dmajblfhsg"), 1, 1);
test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1);
test(S("cshmd"), S(""), 2, S::npos);
test(S("lhcdo"), S("oebqi"), 2, 4);
test(S("qnsoh"), S("kojhpmbsfe"), 2, 2);
test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2);
test(S("fmtsp"), S(""), 4, S::npos);
test(S("khbpm"), S("aobjd"), 4, S::npos);
test(S("pbsji"), S("pcbahntsje"), 4, S::npos);
test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4);
test(S("eqmpa"), S(""), 5, S::npos);
test(S("omigs"), S("kocgb"), 5, S::npos);
test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
test(S("schfa"), S(""), 6, S::npos);
test(S("igdsc"), S("qngpd"), 6, S::npos);
test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
test(S("hcjitbfapl"), S(""), 0, S::npos);
test(S("daiprenocl"), S("ashjd"), 0, 0);
test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0);
test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0);
test(S("qpghtfbaji"), S(""), 1, S::npos);
test(S("gfshlcmdjr"), S("nadkh"), 1, 3);
test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1);
test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1);
test(S("crnklpmegd"), S(""), 5, S::npos);
test(S("jsbtafedoc"), S("prqgn"), 5, S::npos);
test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5);
test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5);
test(S("lmofqdhpki"), S(""), 9, S::npos);
test(S("hnefkqimca"), S("rtjpa"), 9, 9);
test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, S::npos);
test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9);
test(S("elgofjmbrq"), S(""), 10, S::npos);
test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
test(S("eqsgalomhb"), S(""), 11, S::npos);
test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos);
test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 3);
test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0);
test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0);
test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos);
test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 3);
test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1);
test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1);
test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos);
test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10);
test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10);
test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10);
test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos);
test(S("copqdhstbingamjfkler"), S("djkqc"), 19, S::npos);
test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19);
test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19);
test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
}

template <class S>
void test1()
{
test(S(""), S(""), S::npos);
test(S(""), S("laenf"), S::npos);
test(S(""), S("pqlnkmbdjo"), S::npos);
test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
test(S("nhmko"), S(""), S::npos);
test(S("lahfb"), S("irkhs"), 2);
test(S("gmfhd"), S("kantesmpgj"), 0);
test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 0);
test(S("eolhfgpjqk"), S(""), S::npos);
test(S("nbatdlmekr"), S("bnrpe"), 0);
test(S("jdmciepkaq"), S("jtdaefblso"), 0);
test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 0);
test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos);
test(S("qjghlnftcaismkropdeb"), S("bjaht"), 1);
test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 0);
test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 0);
}

int main()
{
{
typedef std::experimental::string_view S;
test0<S>();
test1<S>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string_view>

// const size_type find_last_not_of(charT c, size_type pos = npos) const;

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type pos,
typename S::size_type x)
{
assert(s.find_last_not_of(c, pos) == x);
if (x != S::npos)
assert(x <= pos && x < s.size());
}

template <class S>
void
test(const S& s, typename S::value_type c, typename S::size_type x)
{
assert(s.find_last_not_of(c) == x);
if (x != S::npos)
assert(x < s.size());
}

int main()
{
{
typedef std::experimental::string_view S;
test(S(""), 'i', 0, S::npos);
test(S(""), 'i', 1, S::npos);
test(S("kitcj"), 'i', 0, 0);
test(S("qkamf"), 'i', 1, 1);
test(S("nhmko"), 'i', 2, 2);
test(S("tpsaf"), 'i', 4, 4);
test(S("lahfb"), 'i', 5, 4);
test(S("irkhs"), 'i', 6, 4);
test(S("gmfhdaipsr"), 'i', 0, 0);
test(S("kantesmpgj"), 'i', 1, 1);
test(S("odaftiegpm"), 'i', 5, 4);
test(S("oknlrstdpi"), 'i', 9, 8);
test(S("eolhfgpjqk"), 'i', 10, 9);
test(S("pcdrofikas"), 'i', 11, 9);
test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);

test(S(""), 'i', S::npos);
test(S("csope"), 'i', 4);
test(S("gfsmthlkon"), 'i', 9);
test(S("laenfsbridchgotmkqpj"), 'i', 19);
}

#if _LIBCPP_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_last_not_of( 'i', 0 ) == SV::npos, "" );
static_assert (sv1.find_last_not_of( 'i', 1 ) == SV::npos, "" );
static_assert (sv2.find_last_not_of( 'a', 0 ) == SV::npos, "" );
static_assert (sv2.find_last_not_of( 'a', 1 ) == 1, "" );
static_assert (sv2.find_last_not_of( 'e', 5 ) == 3, "" );
}
#endif
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <string_view>

// constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;

#include <experimental/string_view>
#include <cassert>

#include "constexpr_char_traits.hpp"

template <class S>
void
test(const S& s, const typename S::value_type* str, typename S::size_type pos,
typename S::size_type x)
{
assert(s.find_last_not_of(str, pos) == x);
if (x != S::npos)
assert(x <= pos && x < s.size());
}

template <class S>
void
test(const S& s, const typename S::value_type* str, typename S::size_type x)
{
assert(s.find_last_not_of(str) == x);
if (x != S::npos)
assert(x < s.size());
}

template <class S>
void test0()
{
test(S(""), "", 0, S::npos);
test(S(""), "laenf", 0, S::npos);
test(S(""), "pqlnkmbdjo", 0, S::npos);
test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
test(S(""), "", 1, S::npos);
test(S(""), "bjaht", 1, S::npos);
test(S(""), "hjlcmgpket", 1, S::npos);
test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
test(S("fodgq"), "", 0, 0);
test(S("qanej"), "dfkap", 0, 0);
test(S("clbao"), "ihqrfebgad", 0, 0);
test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
test(S("srdfq"), "", 1, 1);
test(S("oemth"), "ikcrq", 1, 1);
test(S("cdaih"), "dmajblfhsg", 1, 0);
test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
test(S("cshmd"), "", 2, 2);
test(S("lhcdo"), "oebqi", 2, 2);
test(S("qnsoh"), "kojhpmbsfe", 2, 1);
test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
test(S("fmtsp"), "", 4, 4);
test(S("khbpm"), "aobjd", 4, 4);
test(S("pbsji"), "pcbahntsje", 4, 4);
test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
test(S("eqmpa"), "", 5, 4);
test(S("omigs"), "kocgb", 5, 4);
test(S("onmje"), "fbslrjiqkm", 5, 4);
test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
test(S("schfa"), "", 6, 4);
test(S("igdsc"), "qngpd", 6, 4);
test(S("brqgo"), "rodhqklgmb", 6, S::npos);
test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
test(S("hcjitbfapl"), "", 0, 0);
test(S("daiprenocl"), "ashjd", 0, S::npos);
test(S("litpcfdghe"), "mgojkldsqh", 0, S::npos);
test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
test(S("qpghtfbaji"), "", 1, 1);
test(S("gfshlcmdjr"), "nadkh", 1, 1);
test(S("nkodajteqp"), "ofdrqmkebl", 1, 0);
test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
test(S("crnklpmegd"), "", 5, 5);
test(S("jsbtafedoc"), "prqgn", 5, 5);
test(S("qnmodrtkeb"), "pejafmnokr", 5, 4);
test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
test(S("lmofqdhpki"), "", 9, 9);
test(S("hnefkqimca"), "rtjpa", 9, 8);
test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
test(S("elgofjmbrq"), "", 10, 9);
test(S("mjqdgalkpc"), "dplqa", 10, 9);
test(S("kthqnfcerm"), "dkacjoptns", 10, 9);
test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
test(S("eqsgalomhb"), "", 11, 9);
test(S("akiteljmoh"), "lofbc", 11, 9);
test(S("hlbdfreqjo"), "astoegbfpn", 11, 8);
test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, S::npos);
test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 0);
test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 9);
test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 9);
test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
test(S("niptglfbosehkamrdqcj"), "", 19, 19);
test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 16);
test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
test(S("eaintpchlqsbdgrkjofm"), "", 20, 19);
test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 18);
test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 19);
test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
test(S("liatsqdoegkmfcnbhrpj"), "", 21, 19);
test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 19);
test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 19);
test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
}

template <class S>
void test1()
{
test(S(""), "", S::npos);
test(S(""), "laenf", S::npos);
test(S(""), "pqlnkmbdjo", S::npos);
test(S(""), "qkamfogpnljdcshbreti", S::npos);
test(S("nhmko"), "", 4);
test(S("lahfb"), "irkhs", 4);
test(S("gmfhd"), "kantesmpgj", 4);
test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
test(S("eolhfgpjqk"), "", 9);
test(S("nbatdlmekr"), "bnrpe", 8);
test(S("jdmciepkaq"), "jtdaefblso", 9);
test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
test(S("gprdcokbnjhlsfmtieqa"), "", 19);
test(S("qjghlnftcaismkropdeb"), "bjaht", 18);
test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 17);
test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
}

int main()
{
{
typedef std::experimental::string_view S;
test0<S>();
test1<S>();
}

#if _LIBCPP_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_last_not_of( "", 0) == SV::npos, "" );
static_assert (sv1.find_last_not_of( "irkhs", 5) == SV::npos, "" );
static_assert (sv2.find_last_not_of( "", 0) == 0, "" );
static_assert (sv2.find_last_not_of( "gfsrt", 5) == 4, "" );
static_assert (sv2.find_last_not_of( "lecar", 5) == 3, "" );
}
#endif
}
Loading