1
0
forked from boostorg/core

Compare commits

..

136 Commits

Author SHA1 Message Date
Glen Fernandes
a4172b4319 MSVC warning workaround for empty_value 2021-11-01 06:33:44 -04:00
Peter Dimov
e4fb94b73c Merge branch 'develop' into feature/warnings-as-errors 2021-11-01 05:12:33 +02:00
Peter Dimov
ef3505db59 Disable -Wtype-limits for g++ 4.4 in Jamfile 2021-11-01 04:44:07 +02:00
Peter Dimov
f94db671f6 Disable C4702 in lightweight_test_fail6, no_exceptions_support_test 2021-11-01 04:17:51 +02:00
Peter Dimov
7b45315af1 Avoid C4996 in sv_copy_test.cpp 2021-11-01 04:15:33 +02:00
Peter Dimov
bdd4bf7d9a #pragma GCC diagnostic push requires g++ 4.6 2021-11-01 04:04:52 +02:00
Peter Dimov
9f2cdfa7d2 Disable C4244 in scoped_enum.cpp, underlying_type.cpp 2021-11-01 03:58:37 +02:00
Peter Dimov
964ef98eee Avoid streamsize -> size_t warning in string_view.hpp 2021-11-01 03:52:09 +02:00
Peter Dimov
f09ab90243 Disable -Wsign-compare for g++ 4.4 2021-11-01 03:14:53 +02:00
Glen Fernandes
d2e897fd60 MSVC warning workaround for dynamic_extent 2021-10-31 21:14:40 -04:00
Peter Dimov
66f6ea594a Disable -Wtype-limits in string_view.hpp 2021-11-01 03:10:42 +02:00
Peter Dimov
6a91536da6 Disable -Wunused-function in swap_array(_of_array)_of_class.cpp 2021-11-01 03:05:47 +02:00
Peter Dimov
c3a398b9a0 Merge branch 'develop' into feature/warnings-as-errors 2021-11-01 02:56:47 +02:00
Peter Dimov
e73e8bfc83 Disable C4512 in uncaught_exceptions(_np).cpp 2021-11-01 02:55:52 +02:00
Glen Fernandes
633a47f85b MSVC warning workaround for destroy 2021-10-31 20:52:44 -04:00
Glen Fernandes
eae98e909e MSVC warning workaround for as_bytes 2021-10-31 20:52:23 -04:00
Peter Dimov
a581a42c4f Disable C4577 in no_exceptions_support_test.cpp 2021-11-01 02:50:16 +02:00
Peter Dimov
e44781e290 Avoid C4101 in explicit_operator_bool_noexcept.cpp 2021-11-01 02:44:24 +02:00
Peter Dimov
11958e9568 Avoid C4101 in scoped_enum.cpp 2021-11-01 02:42:03 +02:00
Peter Dimov
56566d9abc Disable C4100 in alloc_construct_cxx11_test.cpp 2021-11-01 02:38:19 +02:00
Peter Dimov
9efeed68cb Disable C4530 in no_exceptions_support_test.cpp 2021-11-01 02:32:49 +02:00
Peter Dimov
da3c89dc5b Apply a better fix to iterator_test.cpp 2021-11-01 02:26:06 +02:00
Peter Dimov
ba208ad7fc Avoid signed/unsigned mismatch warning in span.hpp 2021-11-01 02:20:26 +02:00
Peter Dimov
bbfa6344fa Avoid ptrdiff_t -> int warning in eif_constructors.cpp 2021-11-01 02:18:51 +02:00
Peter Dimov
bf4354a3a4 Disable C4127 in bit_endian_test.cpp 2021-11-01 02:16:31 +02:00
Peter Dimov
a4b661068d Disable C4127, C4244 in bit.hpp 2021-11-01 02:14:43 +02:00
Peter Dimov
8299d25eb2 Avoid size_t to int conversion warning in visit_each_test.cpp 2021-11-01 02:06:42 +02:00
Peter Dimov
847f9d43fe Disable C4702 in quick_exit_test.cpp, quick_exit_fail.cpp 2021-11-01 02:04:45 +02:00
Peter Dimov
44e294fff1 Avoid unused parameter warning in to_address_test.cpp 2021-11-01 01:58:05 +02:00
Peter Dimov
b5f59858b9 Avoid unused parameter warning in visit_each_test.cpp 2021-11-01 01:56:27 +02:00
Peter Dimov
bed07e7d5b Disable -Wdeprecated-declarations in iterator_test.cpp 2021-11-01 01:47:28 +02:00
Peter Dimov
971cda2e4c Avoid -Wmissing-braces in swap_array_of_template.cpp 2021-11-01 01:45:15 +02:00
Peter Dimov
d81c61abb4 Disable -Wstring-plus-int in lightweight_test_fail10.cpp 2021-11-01 01:43:50 +02:00
Peter Dimov
370a74c249 Avoid self-assignment warning in ref_ct_test.cpp 2021-11-01 01:41:54 +02:00
Peter Dimov
62d1b1bb59 Avoid sturct/class mismatch warning in use_default_test.cpp 2021-11-01 01:39:13 +02:00
Peter Dimov
bb99544852 Use warnings-as-errors=off for compile-fail tests 2021-11-01 01:35:57 +02:00
Peter Dimov
9b5bf05fae Disable -Wdeprecated-declarations in get_pointer_test.cpp 2021-11-01 01:29:15 +02:00
Peter Dimov
309a6bb797 Fix unused parameter 't' warnings in eif_*.cpp 2021-11-01 01:27:01 +02:00
Peter Dimov
9d1b59ec6c Enable warnings=extra, warnings-as-errors=on 2021-11-01 01:24:02 +02:00
Glen Fernandes
12f5f51427 Switch tests to not rely on requires checks 2021-10-27 01:41:40 -04:00
Peter Dimov
0565456622 Use boost::(u)long_long_type to avoid g++ warning 2021-10-27 04:45:40 +03:00
Peter Dimov
fda0f87576 Add void, move nullptr_t to fundamental type section 2021-10-27 03:46:06 +03:00
Peter Dimov
e9718374ac Hardcode all integral and floating point types 2021-10-27 03:41:40 +03:00
Peter Dimov
79b7c49fb3 Refactor typeid_name<T> slighlty 2021-10-27 03:20:22 +03:00
Peter Dimov
585ac9ace1 Move string_view.hpp to boost/core/detail 2021-10-27 03:08:10 +03:00
Peter Dimov
493832a570 Remove string_view from documentation 2021-10-27 02:57:55 +03:00
Peter Dimov
8942e8ecc9 Update cmake_subdir_test/CMakeLists.txt 2021-10-26 01:00:15 +03:00
Peter Dimov
cbf03c4b9c Add msvc-14.3 to GHA 2021-10-26 00:54:37 +03:00
Glen Fernandes
5cf3569218 Correct documentation 2021-10-20 22:26:25 -04:00
Peter Dimov
d5bd40e528 Update test/Jamfile and test/CMakeLists.txt so that missing dependencies are caught 2021-10-16 18:10:13 +03:00
Peter Dimov
0e57df5aab Regenerate CMakeLists.txt 2021-10-16 17:55:35 +03:00
Glen Fernandes
62b23df9ef Update revision history 2021-10-15 19:00:57 -04:00
Glen Fernandes
fdf1ed78a7 Contribute span implementation 2021-10-14 21:16:19 -04:00
Peter Dimov
e02c333706 Update string_view.qbk 2021-10-11 02:09:45 +03:00
Peter Dimov
b677d1eeae Only update the necessary submodules in ci.yml 2021-10-10 19:35:26 +03:00
Peter Dimov
0f7d02de01 Update revision history 2021-10-10 19:29:46 +03:00
Peter Dimov
773499db5e Remove concurrency section from ci.yml 2021-10-10 18:23:21 +03:00
Peter Dimov
ce912859aa Change cancel-in-progress to false in ci.yml 2021-10-10 18:22:08 +03:00
Peter Dimov
bfeee019dd Update revision history 2021-10-10 18:20:46 +03:00
Peter Dimov
220d4ae0a9 Improve starts_with/ends_with 2021-10-10 17:47:57 +03:00
Peter Dimov
5d7b469e29 Improve .find 2021-10-10 03:09:53 +03:00
Peter Dimov
3cec508460 Update string_view.qbk 2021-10-10 02:25:50 +03:00
Peter Dimov
a47fac1449 Update string_view.qbk 2021-10-10 02:04:43 +03:00
Peter Dimov
7340f123fe Update string_view.qbk 2021-10-10 01:46:32 +03:00
Peter Dimov
038064e824 Update string_view.qbk 2021-10-10 00:44:00 +03:00
Peter Dimov
52c58efc36 Improve operator== 2021-10-09 21:04:38 +03:00
Peter Dimov
15fdc0ab39 Test std::pmr::string in sv_lt_test 2021-10-09 20:14:06 +03:00
Peter Dimov
b520289660 Test std::pmr::string in sv_eq_test 2021-10-09 20:12:32 +03:00
Peter Dimov
9b22937647 g++ 11 has <memory_resource> but not std::pmr::string 2021-10-09 20:06:20 +03:00
Peter Dimov
903d44c0c5 Test std::pmr::string in sv_conversion_test 2021-10-09 19:52:10 +03:00
Peter Dimov
88eee0c628 Test std::pmr::string in sv_construct_test 2021-10-09 19:50:34 +03:00
Peter Dimov
54965f567d Add an allocator argument to operator string() 2021-10-09 19:50:15 +03:00
Peter Dimov
c43a172ded Use os << "" for the padding instead of os << p[0] 2021-10-09 19:31:41 +03:00
Peter Dimov
ddf9b5087b Add sv_conversion_test 2021-10-09 18:36:05 +03:00
Peter Dimov
d17313d407 Add missing #include <ios> 2021-10-09 18:00:58 +03:00
Peter Dimov
c8b860704e Add sv_stream_insert_test 2021-10-09 17:36:06 +03:00
Peter Dimov
e9ffc4336c Remove unused npos variables 2021-10-09 17:10:52 +03:00
Peter Dimov
a121d5a000 Add sv_lt_test 2021-10-09 17:09:23 +03:00
Peter Dimov
5c82e38c93 Add other relational operators; update sv_eq_test 2021-10-09 16:55:33 +03:00
Peter Dimov
db15c7419d Add sv_eq_test 2021-10-09 16:50:14 +03:00
Peter Dimov
62e9d9b868 Update tests 2021-10-09 07:13:56 +03:00
Peter Dimov
b01f2fe4d2 Add optimized implementation of find_last_not_of 2021-10-09 07:08:48 +03:00
Peter Dimov
408cd96595 Update sv_find_last_not_of_test 2021-10-09 07:00:32 +03:00
Peter Dimov
9f2ec3bfca Update find_first_not_of_test 2021-10-09 06:58:11 +03:00
Peter Dimov
63f3a97a15 Update find_last_of_test 2021-10-09 06:54:23 +03:00
Peter Dimov
b70bbf14db Update sv_find_first_of_test 2021-10-09 06:52:08 +03:00
Peter Dimov
b251310a8f Update implementation of find_last_of 2021-10-09 06:47:39 +03:00
Peter Dimov
969a201c75 Update implementation of find_first_of 2021-10-09 06:43:48 +03:00
Peter Dimov
b9f1b9f39a Add optimized implementation of find_first_not_of 2021-10-09 06:40:59 +03:00
Peter Dimov
3d4eb536cd Add optimized implementation of find_last_of 2021-10-09 05:13:23 +03:00
Peter Dimov
a51364c5d3 sv_find_last_not_of_test 2021-10-09 03:33:10 +03:00
Peter Dimov
ab3950fdfb Add sv_find_first_not_of_test 2021-10-09 03:09:32 +03:00
Peter Dimov
fe9c0164c0 Add sv_find_last_of_test 2021-10-09 02:32:00 +03:00
Peter Dimov
8ec0e7f68a Merge branch 'develop' into feature/string-view 2021-10-09 01:50:17 +03:00
Peter Dimov
85e24f0483 Disable std::tuple tests on msvc-10.0 2021-10-08 18:21:04 +03:00
Peter Dimov
be820fea2e Remove uint64_t mask path from find_first_of; no longer a win after fix 2021-10-08 10:28:06 +03:00
Peter Dimov
af3e6a667b Update sv_find_first_of_test 2021-10-08 10:21:07 +03:00
Peter Dimov
c3cfe7a861 Merge branch 'develop' into feature/string-view 2021-10-08 10:15:05 +03:00
Peter Dimov
d87766a768 Remove no longer necessary workarounds 2021-10-08 10:14:21 +03:00
Peter Dimov
706747ab08 Work around g++'s instantiating X on typeid(X*) 2021-10-08 09:44:23 +03:00
Peter Dimov
41c3b6a7dd Reimplement type_name with class templates to avoid instantiating types such as pair<void, void> and tuple<void> 2021-10-08 09:23:26 +03:00
Peter Dimov
8223ff03e4 Add char8_t tests to sv_find_first_of_test 2021-10-08 07:14:54 +03:00
Peter Dimov
18334b1614 Add optimized implementation of find_first_of 2021-10-08 07:03:39 +03:00
Peter Dimov
df65ea6600 Update sv_find_first_of_test 2021-10-08 06:21:52 +03:00
Peter Dimov
d1ad50cefb Add sv_contains_test 2021-10-08 05:50:00 +03:00
Peter Dimov
09870f0739 Add sv_find_first_of_test 2021-10-08 05:39:24 +03:00
Peter Dimov
95e64ef71f Fix msvc-14.0 failure 2021-10-06 17:45:10 +03:00
Peter Dimov
673e3c302c Add sv_rfind_test 2021-10-06 05:49:09 +03:00
Peter Dimov
a8e7a3395e Add sv_iteration_test 2021-10-06 05:36:12 +03:00
Peter Dimov
09044f58d6 Add sv_find_test 2021-10-06 05:04:32 +03:00
Peter Dimov
f9fa1772f2 Add sv_ends_with_test 2021-10-06 04:39:16 +03:00
Peter Dimov
c7dfa29f29 Add sv_starts_with_test 2021-10-06 04:38:27 +03:00
Peter Dimov
93c18fb937 Use BOOST_TEST_TRAIT_SAME in sv_types_test 2021-10-06 03:36:40 +03:00
Peter Dimov
c005ad5e55 Merge branch 'develop' into feature/string-view 2021-10-06 03:32:05 +03:00
Peter Dimov
8cf4d16297 Merge branch 'feature/type-name' into feature/lwt-type-name 2021-10-05 19:47:11 +03:00
Peter Dimov
0deaa2d502 Update msvc-12.0 workaround 2021-10-05 19:22:20 +03:00
Peter Dimov
22de922125 Merge branch 'develop' into feature/type-name 2021-10-05 19:17:39 +03:00
Peter Dimov
531726eb09 Update msvc workarounds in type_name_test 2021-10-05 19:05:40 +03:00
Peter Dimov
31a9336778 Merge branch 'develop' into feature/lwt-type-name 2021-10-05 18:47:25 +03:00
Peter Dimov
87c21a23bb Update copyright 2021-10-05 17:32:50 +03:00
Peter Dimov
3e9cc2153b Disable no-rtti tests for g++ 4.4 because <memory> breaks 2021-10-05 17:11:31 +03:00
Peter Dimov
98630095f3 Merge branch 'develop' into feature/lwt-type-name 2021-10-05 16:24:49 +03:00
Peter Dimov
b3906601f7 Merge branch 'feature/type-name' into feature/lwt-type-name 2021-10-05 05:43:01 +03:00
Peter Dimov
3b5595e940 Merge branch 'feature/type-name' into feature/lwt-type-name 2021-10-05 05:31:09 +03:00
Peter Dimov
290340fd27 Use core::type_name in lightweight_test_trait 2021-10-05 04:58:52 +03:00
Peter Dimov
31e2caef12 Add sv_compare_test 2021-10-04 22:11:14 +03:00
Peter Dimov
042bb98142 Add sv_substr_test 2021-10-04 20:57:10 +03:00
Peter Dimov
c65c05c006 Add sv_copy_test 2021-10-04 20:45:10 +03:00
Peter Dimov
1aa8341bd7 Add sv_modifiers_test 2021-10-04 20:36:40 +03:00
Peter Dimov
e206cddc6f Fix line endings 2021-10-04 20:27:14 +03:00
Peter Dimov
c8b55f1bde Change BOOST_CONSTEXPR to BOOST_CXX14_CONSTEXPR appropriately 2021-10-04 19:12:05 +03:00
Peter Dimov
62ba7ca18b Define npos as BOOST_CONSTEXPR_OR_CONST 2021-10-04 19:08:12 +03:00
Peter Dimov
964dfe2b74 Fix line endings 2021-10-04 17:45:24 +03:00
Peter Dimov
016ae92ecf Add sv_element_access_test 2021-10-04 17:33:04 +03:00
Peter Dimov
7d05dfa87d Add sv_construct_test 2021-10-04 17:25:34 +03:00
Peter Dimov
95924b1329 Add boost/core/string_view.hpp 2021-10-04 16:49:46 +03:00
70 changed files with 9047 additions and 546 deletions

View File

@@ -14,10 +14,6 @@ on:
- develop
- feature/**
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
GIT_FETCH_JOBS: 8
NET_RETRY_COUNT: 5
@@ -343,7 +339,6 @@ jobs:
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
DEPINST_ARGS=()
GIT_VERSION="$(git --version | sed -e 's/git version //')"
GIT_HAS_JOBS=1
if [ -f "/etc/debian_version" ]
@@ -370,16 +365,23 @@ jobs:
fi
if [ "$GIT_HAS_JOBS" -ne 0 ]
then
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
GIT_ARGS="--jobs $GIT_FETCH_JOBS"
fi
cd ..
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
cd boost-root
mkdir -p libs/$LIBRARY
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
DEPINST_ARGS+=("$LIBRARY")
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
git submodule init tools/boost_install
git submodule init libs/headers
git submodule init tools/build
git submodule init tools/cmake
git submodule init libs/assert
git submodule init libs/config
git submodule init libs/static_assert
git submodule init libs/throw_exception
git submodule init libs/type_traits
git submodule update $GIT_ARGS
if [ -z "${{matrix.cmake_tests}}" ]
then
./bootstrap.sh
@@ -470,6 +472,10 @@ jobs:
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
@@ -497,8 +503,16 @@ jobs:
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
git submodule init tools/boost_install
git submodule init libs/headers
git submodule init tools/build
git submodule init tools/cmake
git submodule init libs/assert
git submodule init libs/config
git submodule init libs/static_assert
git submodule init libs/throw_exception
git submodule init libs/type_traits
git submodule update --jobs %GIT_FETCH_JOBS%
cmd /c bootstrap
b2 -d0 headers

View File

@@ -1,8 +1,9 @@
# Copyright 2018, 2019 Peter Dimov
# Generated by `boostdep --cmake core`
# Copyright 2020, 2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
cmake_minimum_required(VERSION 3.5...3.20)
project(boost_core VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
@@ -15,9 +16,11 @@ target_link_libraries(boost_core
INTERFACE
Boost::assert
Boost::config
Boost::static_assert
Boost::throw_exception
)
if(BUILD_TESTING)
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)

View File

@@ -10,7 +10,8 @@
* Added a generic implementation to `boost/core/cmath.hpp`, enabled when `BOOST_CORE_USE_GENERIC_CMATH`
is defined or when the platform does not provide the necessary facilities in `<cmath>`.
* Added `boost::core::type_name`.
* Added `boost::core::type_name`, a utility function that returns the name of a type as a string.
* Added `boost::span`, a C++11 implementation of C++20's `std::span`.
[endsect]
@@ -22,11 +23,11 @@
[section Changes in 1.76.0]
* Add implicit conversion between compatible reference wrappers.
* Add `boost/core/cmath.hpp`, a portable implementation of the floating point classification functions from `<cmath>`.
* Add `boost/core/bit.hpp`, a portable implementation of the C++20 standard header `<bit>`.
* Fix `BOOST_TEST_EQ`, `BOOST_TEST_NE` for character types under C++20.
* Revise allocator access utilities (now support VS2013, and no workarounds use `allocator_traits`.)
* Added implicit conversion between compatible reference wrappers.
* Added `boost/core/cmath.hpp`, a portable implementation of the floating point classification functions from `<cmath>`.
* Added `boost/core/bit.hpp`, a portable implementation of the C++20 standard header `<bit>`.
* Fixed `BOOST_TEST_EQ`, `BOOST_TEST_NE` for character types under C++20.
* Revised allocator access utilities (now support VS2013, and no workarounds use `allocator_traits`.)
[endsect]
@@ -35,6 +36,7 @@
* Implemented the allocator access utilities which provide a replacement for `allocator_traits`
with individual traits and functions for each facility. They support the C++11 allocator model
when possible and provide a fallback for C++98 compatibility.
* Added `BOOST_TEST_WITH` to Lightweight Test.
[endsect]

View File

@@ -34,7 +34,7 @@ criteria for inclusion is that the utility component be:
* simple,
* used by other Boost libraries, and
* not dependent on any other Boost modules except Core
itself, Config, Assert, Static Assert, or Predef.
itself, Config, Assert, or Static Assert.
[endsect]
@@ -65,6 +65,7 @@ criteria for inclusion is that the utility component be:
[include quick_exit.qbk]
[include ref.qbk]
[include scoped_enum.qbk]
[include span.qbk]
[include swap.qbk]
[include typeinfo.qbk]
[include type_name.qbk]

404
doc/span.qbk Normal file
View File

@@ -0,0 +1,404 @@
[/
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:span span]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
This header <boost/core/span.hpp> provides class template `span`, which is a
view over a sequence of objects. It implements the C++20 standard library
`std::span` facility. This implementation supports C++11 and higher.
In addition to referencing the sequence of objects, the span knows the count of
objects. There are two kinds of spans:
* Dynamic size (`span<T>` or `span<T, dynamic_extent>`)
* Static size (`span<T, N>`)
Dynamic size spans have a count that can be a value known at run time. Static
size spans have a count that must be known at compile time.
[endsect]
[section Examples]
The following snippet shows a function to compute a SHA1 hash whose parameters
and return type use spans.
```
auto sha1(boost::span<const unsigned char> input,
boost::span<unsigned char, SHA_DIGEST_LENGTH> ouput)
{
SHA_CTX context;
SHA1_Init(&context);
SHA1_Update(&context, input.data(), input.size());
SHA1_Final(output.data(), &context);
return output;
}
```
[endsect]
[section Reference]
```
namespace boost {
constexpr std::size_t dynamic_extent = -1;
template<class T, std::size_t E = dynamic_extent>
class span {
public:
typedef T element_type;
typedef std::remove_cv_t<T> value_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T* iterator;
typedef const T* const_iterator;
typedef std::reverse_iterator<T*> reverse_iterator;
typedef std::reverse_iterator<const T*> const_reverse_iterator;
static constexpr std::size_t extent = E;
constexpr span() noexcept;
explicit(E != dynamic_extent)
template<class I>
constexpr span(I* f, size_type c);
explicit(E != dynamic_extent)
template<class I, class L>
constexpr span(I* f, L* l);
template<std::size_t N>
constexpr span(type_identity_t<T> (&a)[N]);
template<class U, std::size_t N>
constexpr span(std::array<U, N>& a) noexcept;
template<class U, std::size_t N>
constexpr span(const std::array<U, N>& a) noexcept;
explicit(E != dynamic_extent)
template<class R>
constexpr span(R&& r);
explicit(E != dynamic_extent && N == dynamic_extent)
template<class U, std::size_t N>
constexpr span(const span<U, N>& s) noexcept;
template<std::size_t C>
constexpr span<T, C> first() const;
template<std::size_t C>
constexpr span<T, C> last() const;
template<std::size_t O, std::size_t C = dynamic_extent>
constexpr span<T, see below> subspan() const;
constexpr span<T, dynamic_extent> first(size_type c) const;
constexpr span<T, dynamic_extent> last(size_type c) const;
constexpr span<T, dynamic_extent> subspan(size_type o,
size_type c = dynamic_extent) const;
constexpr size_type size() const noexcept;
constexpr size_type size_bytes() const noexcept;
constexpr bool empty() const noexcept;
constexpr reference operator[](size_type i) const;
constexpr reference front() const;
constexpr reference back() const;
constexpr pointer data() const noexcept;
constexpr iterator begin() const noexcept;
constexpr iterator end() const noexcept;
constexpr reverse_iterator rbegin() const noexcept;
constexpr reverse_iterator rend() const noexcept;
constexpr const_iterator cbegin() const noexcept;
constexpr const_iterator cend() const noexcept;
constexpr const_reverse_iterator crbegin() const noexcept;
constexpr const_reverse_iterator crend() const noexcept;
friend constexpr iterator begin(span s) noexcept {
return s.begin();
}
friend constexpr iterator end(span s) noexcept {
return s.end();
}
};
template<class I, class L>
span(I*, L) -> span<I>;
template<class T, std::size_t N>
span(T(&)[N]) -> span<T, N>;
template<class T, std::size_t N>
span(std::array<T, N>&) -> span<T, N>;
template<class T, std::size_t N>
span(const std::array<T, N>&) -> span<const T, N>;
template<class R>
span(R&&) -> span<std::remove_pointer_t<decltype(std::declval<R&>().data())> >;
template<class T, std::size_t E>
span<const std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
as_bytes(span<T, E> s) noexcept;
template<class T, std::size_t E>
span<std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
as_writable_bytes(span<T, E> s) noexcept;
} /* boost */
```
[section Constructors]
[variablelist
[[`constexpr span() noexcept;`]
[[variablelist
[[Constraints][`E == dynamic_extent || E == 0` is `true`.]]
[[Postconditions][`size() == 0 && data() == nullptr`.]]]]]
[[`explicit(E != dynamic_extent)
template<class I>
constexpr span(I* f, size_type c);`]
[[variablelist
[[Constraints]
[`is_convertible_v<I(*)[], T(*)[]>` is `true`.]]
[[Preconditions]
[[itemized_list
[`[f, f + c)` is a valid range.]
[If `E` is not equal to `dynamic_extent`, then `c` is equal to `E`.]]]]
[[Effects][Constructs a `span` with data `f` and size `c`.]]
[[Throws][Nothing.]]]]]
[[`explicit(E != dynamic_extent)
template<class I, class L>
constexpr span(I* f, L* l);`]
[[variablelist
[[Constraints]
[`is_convertible_v<I(*)[], T(*)[]>` is `true`.]]
[[Preconditions]
[[itemized_list
[If `E` is not equal to `dynamic_extent`, then `l - f` is equal to `E`.]
[`[f, l)` is a valid range.]]]]
[[Effects][Constructs a `span` with data `f` and size `l - f`.]]
[[Throws][Nothing.]]]]]
[[`template<std::size_t N>
constexpr span(type_identity_t<T> (&a)[N]);`]
[[variablelist
[[Constraints][`E == dynamic_extent || E == N` is `true`.]]
[[Effects][Constructs a `span` that is a view over the supplied array.]]
[[Postconditions][`size() == N && data() == &a[0]` is `true`.]]]]]
[[`template<class U, std::size_t N>
constexpr span(std::array<U, N>& a) noexcept;`]
[[variablelist
[[Constraints]
[[itemized_list
[`E == dynamic_extent || E == N` is `true`, and]
[`U(*)[]` is convertible to `T(*)[]`.]]]]
[[Effects][Constructs a `span` that is a view over the supplied array.]]
[[Postconditions][`size() == N && data() == a.data()` is `true`.]]]]]
[[`template<class U, std::size_t N>
constexpr span(const std::array<U, N>& a) noexcept;`]
[[variablelist
[[Constraints]
[[itemized_list
[`E == dynamic_extent || E == N` is `true`, and]
[`U(*)[]` is convertible to `T(*)[]`.]]]]
[[Effects][Constructs a `span` that is a view over the supplied array.]]
[[Postconditions][`size() == N && data() == a.data()` is `true`.]]]]]
[[`explicit(E != dynamic_extent)
template<class R>
constexpr span(R&& r);`]
[[variablelist
[[Constraints]
[[itemized_list
[`is_lvalue_reference_v<R> || is_const_v<T>` is `true`]
[`remove_cvref_t<R>` is not a specialization of `span`,]
[`remove_cvref_t<R>` is not a specialization of `array`,]
[`is_array_v<remove_cvref_t<R>>` is `false`,]
[`r.data()` is well-formed and
`is_convertible_v<remove_pointer_t<decltype(declval<R&>().data())>(*)[],
T(*)[]>` is `true`, and]
[`r.size()` is well-formed and
`is_convertible_v<decltype(declval<R&>().size()), size_t>` is `true`.]]]]
[[Effects][Constructs a `span` with data `r.data()` and size `r.size()`.]]
[[Throws][What and when r.data() and r.size() throw.]]]]]
[[`explicit(E != dynamic_extent && N == dynamic_extent)
template<class U, std::size_t N>
constexpr span(const span<U, N>& s) noexcept;`]
[[variablelist
[[Constraints]
[[itemized_list
[`E == dynamic_extent || N == dynamic_extent || E == N` is `true`, and]
[`is_convertible_v<U(*)[], T(*)[]>` is `true`.]]]]
[[Preconditions]
[If `E` is not equal to `dynamic_extent`, then `s.size()` is equal to `E`.]]
[[Effects]
[Constructs a `span` that is a view over the range
`[s.data(), s.data() + s.size())`.]]
[[Postconditions][`size() == s.size() && data() == s.data()`.]]]]]]
[endsect]
[section Subviews]
[variablelist
[[`template<std::size_t C> constexpr span<T, C> first() const;`]
[[variablelist
[[Mandates][`C <= E` is `true`.]]
[[Preconditions][`C <= size()` is `true`.]]
[[Effects]
[Equivalent to `return R{data(), C};` where `R` is the return type.]]]]]
[[`template<std::size_t C> constexpr span<T, C> last() const;`]
[[variablelist
[[Mandates][`C <= E` is `true`.]]
[[Preconditions][`C <= size()` is `true`.]]
[[Effects]
[Equivalent to `return R{data() + (size() - C), C};` where `R` is the return
type.]]]]]
[[`template<std::size_t O, std::size_t C = dynamic_extent>
constexpr span<T, see below> subspan() const;`]
[[variablelist
[[Mandates][`O <= E && (C == dynamic_extent || C <= E - O)` is `true`.]]
[[Preconditions]
[`O <= size() && (C == dynamic_extent || C <= size() - O)` is `true`.]]
[[Effects]
[Equivalent to
`return span<T, see below>(data() + O,
C != dynamic_extent ? C : size() - O);`.]]
[[Remarks]
[The second template argument of the returned span type is:
`C != dynamic_extent ? C : (E != dynamic_extent ? E - O :
dynamic_extent)`]]]]]
[[`constexpr span<T, dynamic_extent> first(size_type c) const;`]
[[variablelist
[[Preconditions][`c <= size()` is `true`.]]
[[Effects][Equivalent to: `return {data(), c};`]]]]]
[[`constexpr span<T, dynamic_extent> last(size_type c) const;`]
[[variablelist
[[Preconditions][`c <= size()` is `true`.]]
[[Effects][Equivalent to: `return {data() + (size() - c), c};`]]]]]
[[`constexpr span<T, dynamic_extent> subspan(size_type o,
size_type c = dynamic_extent) const;`]
[[variablelist
[[Preconditions]
[`o <= size() && (c == dynamic_extent || o + c <= size())` is `true`.]]
[[Effects]
[Equivalent to:
`return {data() + o, c == dynamic_extent ? size() - o : c};`]]]]]]
[endsect]
[section Observers]
[variablelist
[[`constexpr size_type size() const noexcept;`]
[[variablelist
[[Returns][The number of elements in the span.]]]]]
[[`constexpr size_type size_bytes() const noexcept;`]
[[variablelist
[[Effects][Equivalent to: `return size() * sizeof(T);`]]]]]
[[`constexpr bool empty() const noexcept;`]
[[variablelist
[[Effects][Equivalent to: `return size() == 0;`]]]]]]
[endsect]
[section Element access]
[variablelist
[[`constexpr reference operator[](size_type i) const;`]
[[variablelist
[[Preconditions][`i < size()` is `true`.]]
[[Effects][Equivalent to: `return *(data() + i);`]]]]]
[[`constexpr reference front() const;`]
[[variablelist
[[Preconditions][`empty()` is `false`.]]
[[Effects][Equivalent to: `return *data();`]]]]]
[[`constexpr reference back() const;`]
[[variablelist
[[Preconditions][`empty()` is `false`.]]
[[Effects][Equivalent to: `return *(data() + (size() - 1);`]]]]]
[[`constexpr pointer data() const noexcept;`]
[[variablelist
[[Returns][A pointer to the first element in the span.]]]]]]
[endsect]
[section Iterator support]
[variablelist
[[`constexpr iterator begin() const noexcept;`]
[[variablelist
[[Returns][A constant iterator referring to the first element in the span. If `empty()`,
then it returns the same value as `cend()`.]]]]]
[[`constexpr iterator end() const noexcept;`]
[[variablelist
[[Returns][A constant iterator which is the past-the-end value.]]]]]
[[`constexpr reverse_iterator rbegin() const noexcept;`]
[[variablelist
[[Effects][Equivalent to: `return reverse_iterator(end());`]]]]]
[[`constexpr reverse_iterator rend() const noexcept;`]
[[variablelist
[[Effects][Equivalent to: `return reverse_iterator(begin());`]]]]]
[[`constexpr const_iterator cbegin() const noexcept;`]
[[variablelist
[[Returns]
[A constant iterator referring to the first element in the span. If `empty()`,
then it returns the same value as `cend()`.]]]]]
[[`constexpr const_iterator cend() const noexcept;`]
[[variablelist
[[Returns][A constant iterator which is the past-the-end value.]]]]]
[[`constexpr const_reverse_iterator crbegin() const noexcept;`]
[[variablelist
[[Effects][Equivalent to: `return const_reverse_iterator(cend());`]]]]]
[[`constexpr const_reverse_iterator crend() const noexcept;`]
[[variablelist
[[Effects]
[Equivalent to: `return const_reverse_iterator(cbegin());`]]]]]]
[endsect]
[section Views of object representation]
[variablelist
[[`template<class T, std::size_t E>
span<const std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
as_bytes(span<T, E> s) noexcept;`]
[[variablelist
[[Effects]
[Equivalent to:
`return {reinterpret_cast<const byte*>(s.data()), s.size_bytes()};`.]]]]]
[[`template<class T, std::size_t E>
span<std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
as_writable_bytes(span<T, E> s) noexcept;`]
[[variablelist
[[Constraints][`is_const_v<T>` is `false`.]]
[[Effects]
[Equivalent to: `return R{reinterpret_cast<byte*>(s.data()), s.size_bytes()};`
where `R` is the return type.]]]]]]
[endsect]
[endsect]
[endsect]

768
doc/string_view.qbk Normal file
View File

@@ -0,0 +1,768 @@
[/
Copyright 2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt
]
[section:string_view string_view]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/string_view.hpp>]
The header `<boost/core/string_view.hpp>` defines `boost::core::string_view`,
a portable and interoperable implementation of `std::string_view`.
Unlike `boost::string_view`, `boost::core::string_view` has implicit
conversions from and to `std::string_view`, which allows Boost libraries that
support C++11/C++14 to use it in interfaces without forcing users to forgo the
use of `std::string_view` in their code.
[section Synopsis]
``
namespace boost
{
namespace core
{
template<class Ch> class basic_string_view
{
public:
// types
typedef std::char_traits<Ch> traits_type;
typedef Ch value_type;
typedef Ch* pointer;
typedef Ch const* const_pointer;
typedef Ch& reference;
typedef Ch const& const_reference;
typedef Ch const* const_iterator;
typedef const_iterator iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef const_reverse_iterator reverse_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
// npos
static constexpr size_type npos = static_cast<size_type>( -1 );
public:
// construction and assignment
constexpr basic_string_view() noexcept;
constexpr basic_string_view( basic_string_view const& ) noexcept = default;
constexpr basic_string_view& operator=( basic_string_view const& ) noexcept & = default;
constexpr basic_string_view( Ch const* str ) noexcept;
constexpr basic_string_view( Ch const* str, size_type len ) noexcept;
constexpr basic_string_view( Ch const* begin, Ch const* end ) noexcept;
template<class A> basic_string_view( std::basic_string<Ch, std::char_traits<Ch>, A> const& str ) noexcept;
basic_string_view( std::basic_string_view<Ch, std::char_traits<Ch>> const& str ) noexcept;
// conversions
template<class A> operator std::basic_string<Ch, std::char_traits<Ch>, A>() const;
template<class Ch2> operator std::basic_string_view<Ch2>() const noexcept;
// iterator support
constexpr const_iterator begin() const noexcept;
constexpr const_iterator end() const noexcept;
constexpr const_iterator cbegin() const noexcept;
constexpr const_iterator cend() const noexcept;
constexpr const_reverse_iterator rbegin() const noexcept;
constexpr const_reverse_iterator rend() const noexcept;
constexpr const_reverse_iterator crbegin() const noexcept;
constexpr const_reverse_iterator crend() const noexcept;
// capacity
constexpr size_type size() const noexcept;
constexpr size_type length() const noexcept;
constexpr size_type max_size() const noexcept;
constexpr bool empty() const noexcept;
// element access
constexpr const_reference operator[]( size_type pos ) const noexcept;
constexpr const_reference at( size_type pos ) const;
constexpr const_reference front() const noexcept;
constexpr const_reference back() const noexcept;
constexpr const_pointer data() const noexcept;
// modifiers
constexpr void remove_prefix( size_type n ) noexcept;
constexpr void remove_suffix( size_type n ) noexcept;
constexpr void swap( basic_string_view& s ) noexcept;
// string operations
constexpr size_type copy( Ch* s, size_type n, size_type pos = 0 ) const;
constexpr basic_string_view substr( size_type pos = 0, size_type n = npos ) const;
// compare
constexpr int compare( basic_string_view str ) const noexcept;
constexpr int compare( size_type pos1, size_type n1, basic_string_view str ) const;
constexpr int compare( size_type pos1, size_type n1, basic_string_view str, size_type pos2, size_type n2 ) const;
constexpr int compare( Ch const* s ) const;
constexpr int compare( size_type pos1, size_type n1, Ch const* s ) const;
constexpr int compare( size_type pos1, size_type n1, Ch const* s, size_type n2 ) const;
// starts_with
constexpr bool starts_with( basic_string_view x ) const noexcept;
constexpr bool starts_with( Ch x ) const noexcept;
constexpr bool starts_with( Ch const* x ) const noexcept;
// ends_with
constexpr bool ends_with( basic_string_view x ) const noexcept;
constexpr bool ends_with( Ch x ) const noexcept;
constexpr bool ends_with( Ch const* x ) const noexcept;
// find
constexpr size_type find( basic_string_view str, size_type pos = 0 ) const noexcept;
constexpr size_type find( Ch c, size_type pos = 0 ) const noexcept;
constexpr size_type find( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type find( Ch const* s, size_type pos = 0 ) const noexcept;
// rfind
constexpr size_type rfind( basic_string_view str, size_type pos = npos ) const noexcept;
constexpr size_type rfind( Ch c, size_type pos = npos ) const noexcept;
constexpr size_type rfind( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type rfind( Ch const* s, size_type pos = npos ) const noexcept;
// find_first_of
constexpr size_type find_first_of( basic_string_view str, size_type pos = 0 ) const noexcept;
constexpr size_type find_first_of( Ch c, size_type pos = 0 ) const noexcept;
constexpr size_type find_first_of( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type find_first_of( Ch const* s, size_type pos = 0 ) const noexcept;
// find_last_of
constexpr size_type find_last_of( basic_string_view str, size_type pos = npos ) const noexcept;
constexpr size_type find_last_of( Ch c, size_type pos = npos ) const noexcept;
constexpr size_type find_last_of( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type find_last_of( Ch const* s, size_type pos = npos ) const noexcept;
// find_first_not_of
constexpr size_type find_first_not_of( basic_string_view str, size_type pos = 0 ) const noexcept;
constexpr size_type find_first_not_of( Ch c, size_type pos = 0 ) const noexcept;
constexpr size_type find_first_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type find_first_not_of( Ch const* s, size_type pos = 0 ) const noexcept;
// find_last_not_of
constexpr size_type find_last_not_of( basic_string_view str, size_type pos = npos ) const noexcept;
constexpr size_type find_last_not_of( Ch c, size_type pos = npos ) const noexcept;
constexpr size_type find_last_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;
constexpr size_type find_last_not_of( Ch const* s, size_type pos = npos ) const noexcept;
// contains
constexpr bool contains( basic_string_view sv ) const noexcept;
constexpr bool contains( Ch c ) const noexcept;
constexpr bool contains( Ch const* s ) const noexcept;
// relational operators
constexpr friend bool operator==( basic_string_view sv1, basic_string_view sv2 ) noexcept;
constexpr friend bool operator!=( basic_string_view sv1, basic_string_view sv2 ) noexcept;
constexpr friend bool operator<( basic_string_view sv1, basic_string_view sv2 ) noexcept;
constexpr friend bool operator<=( basic_string_view sv1, basic_string_view sv2 ) noexcept;
constexpr friend bool operator>( basic_string_view sv1, basic_string_view sv2 ) noexcept;
constexpr friend bool operator>=( basic_string_view sv1, basic_string_view sv2 ) noexcept;
};
// stream inserter
template<class Ch> std::basic_ostream<Ch>& operator<<( std::basic_ostream<Ch>& os, basic_string_view<Ch> str );
// typedef names
typedef basic_string_view<char> string_view;
typedef basic_string_view<wchar_t> wstring_view;
typedef basic_string_view<char16_t> u16string_view;
typedef basic_string_view<char32_t> u32string_view;
typedef basic_string_view<char8_t> u8string_view;
} // namespace core
} // namespace boost
``
[endsect]
[section Construction]
[section `constexpr basic_string_view() noexcept;`]
* *Ensures:* `data() == 0`; `size() == 0`.
[endsect]
[section `constexpr basic_string_view( Ch const* str ) noexcept;`]
* *Ensures:* `data() == str`; `size() == traits_type::length( str )`.
[endsect]
[section `constexpr basic_string_view( Ch const* str, size_type len ) noexcept;`]
* *Ensures:* `data() == str`; `size() == len`.
[endsect]
[section `constexpr basic_string_view( Ch const* begin, Ch const* end ) noexcept;`]
* *Requires:* `end >= begin`.
* *Ensures:* `data() == begin`; `size() == end - begin`.
[endsect]
[section `template<class A> basic_string_view( std::basic_string<Ch, std::char_traits<Ch>, A> const& str ) noexcept;`]
* *Ensures:* `data() == str.data()`; `size() == str.size()`.
[endsect]
[section `basic_string_view( std::basic_string_view<Ch, std::char_traits<Ch>> const& str ) noexcept;`]
* *Ensures:* `data() == str.data()`; `size() == str.size()`.
[endsect]
[endsect]
[section Conversions]
[section `template<class A> operator std::basic_string<Ch, std::char_traits<Ch>, A>() const;`]
* *Returns:* `std::basic_string<Ch, std::char_traits<Ch>, A>( data(), size() )`.
[endsect]
[section `template<class Ch2> operator std::basic_string_view<Ch2>() const noexcept;`]
* *Constraints:* `Ch2` is the same type as `Ch`.
* *Returns:* `std::basic_string_view<Ch2>( data(), size() )`.
[endsect]
[endsect]
[section Iterator Support]
[section `constexpr const_iterator begin() const noexcept;`]
* *Returns:* `data()`.
[endsect]
[section `constexpr const_iterator end() const noexcept;`]
* *Returns:* `data() + size()`.
[endsect]
[section `constexpr const_iterator cbegin() const noexcept;`]
* *Returns:* `begin()`.
[endsect]
[section `constexpr const_iterator cend() const noexcept;`]
* *Returns:* `end()`.
[endsect]
[section `constexpr const_reverse_iterator rbegin() const noexcept;`]
* *Returns:* `const_reverse_iterator( end() )`.
[endsect]
[section `constexpr const_reverse_iterator rend() const noexcept;`]
* *Returns:* `const_reverse_iterator( begin() )`.
[endsect]
[section `constexpr const_reverse_iterator crbegin() const noexcept;`]
* *Returns:* `rbegin()`.
[endsect]
[section `constexpr const_reverse_iterator crend() const noexcept;`]
* *Returns:* `rend()`.
[endsect]
[endsect]
[section Capacity]
[section `constexpr size_type size() const noexcept;`]
* *Returns:* the length of the referenced character sequence.
[endsect]
[section `constexpr size_type length() const noexcept;`]
* *Returns:* `size()`.
[endsect]
[section `constexpr size_type max_size() const noexcept;`]
* *Returns:* `std::numeric_limits<size_type>::max() / sizeof(Ch)`.
[endsect]
[section `constexpr bool empty() const noexcept;`]
* *Returns:* `size() == 0`.
[endsect]
[endsect]
[section Element Access]
[section `constexpr const_reference operator[]( size_type pos ) const noexcept;`]
* *Requires:* `pos < size()`.
* *Returns:* `data()[ pos ]`.
[endsect]
[section `constexpr const_reference at( size_type pos ) const;`]
* *Returns:* `data()[ pos ]`.
* *Throws:* `std::out_of_range` when `pos >= size()`.
[endsect]
[section `constexpr const_reference front() const noexcept;`]
* *Requires:* `!empty()`.
* *Returns:* `data()[ 0 ]`.
[endsect]
[section `constexpr const_reference back() const noexcept;`]
* *Requires:* `!empty()`.
* *Returns:* `data()[ size() - 1 ]`.
[endsect]
[section `constexpr const_pointer data() const noexcept;`]
* *Returns:* a pointer to the beginning of the referenced character sequence.
[endsect]
[endsect]
[section Modifiers]
[section `constexpr void remove_prefix( size_type n ) noexcept;`]
* *Requires:* `n <= size()`.
* *Effects:* advances `data()` by `n` and decreases `size()` by `n`.
[endsect]
[section `constexpr void remove_suffix( size_type n ) noexcept;`]
* *Requires:* `n <= size()`.
* *Effects:* decreases `size()` by `n`.
[endsect]
[section `constexpr void swap( basic_string_view& s ) noexcept;`]
* *Effects:* exchanges the contents of `*this` and `s`.
[endsect]
[endsect]
[section String Operations]
[section copy]
[section `constexpr size_type copy( Ch* s, size_type n, size_type pos = 0 ) const;`]
* *Effects:* copies to `s` the contents of `substr( pos, n )`.
* *Throws:* `std::out_of_range` when `pos >= size()`.
[endsect]
[endsect]
[section substr]
[section `constexpr basic_string_view substr( size_type pos = 0, size_type n = npos ) const;`]
* *Returns:* `basic_string_view( data() + pos, std::min( size() - pos, n ) )`.
* *Throws:* `std::out_of_range` when `pos >= size()`.
[endsect]
[endsect]
[section compare]
[section `constexpr int compare( basic_string_view str ) const noexcept;`]
* *Returns:*
* if `traits_type::compare( data(), str.data(), std::min( size(), str.size() ) )` is not zero, returns it. Otherwise,
* if `size() < str.size()`, returns a negative number. Otherwise,
* if `size() > str.size()`, returns a positive number. Otherwise,
* returns 0.
[endsect]
[section `constexpr int compare( size_type pos1, size_type n1, basic_string_view str ) const;`]
* *Returns:* `substr( pos1, n1 ).compare( str )`.
[endsect]
[section `constexpr int compare( size_type pos1, size_type n1, basic_string_view str, size_type pos2, size_type n2 ) const;`]
* *Returns:* `substr( pos1, n1 ).compare( str.substr( pos2, n2 ) )`.
[endsect]
[section `constexpr int compare( Ch const* s ) const noexcept;`]
* *Returns:* `compare( basic_string_view( s ) )`.
[endsect]
[section `constexpr int compare( size_type pos1, size_type n1, Ch const* s ) const;`]
* *Returns:* `substr( pos1, n1 ).compare( basic_string_view( s ) )`.
[endsect]
[section `constexpr int compare( size_type pos1, size_type n1, Ch const* s, size_type n2 ) const;`]
* *Returns:* `substr( pos1, n1 ).compare( basic_string_view( s, n2 ) )`.
[endsect]
[endsect]
[section starts_with]
[section `constexpr bool starts_with( basic_string_view x ) const noexcept;`]
* *Returns:* `substr( 0, x.size() ) == x`.
[endsect]
[section `constexpr bool starts_with( Ch x ) const noexcept;`]
* *Returns:* `starts_with( basic_string_view( &x, 1 ) )`.
[endsect]
[section `constexpr bool starts_with( Ch const* x ) const noexcept;`]
* *Returns:* `starts_with( basic_string_view( x ) )`.
[endsect]
[endsect]
[section ends_with]
[section `constexpr bool ends_with( basic_string_view x ) const noexcept;`]
* *Returns:* `size() >= x.size() && substr( size() - x.size(), x.size() ) == x`.
[endsect]
[section `constexpr bool ends_with( Ch x ) const noexcept;`]
* *Returns:* `ends_with( basic_string_view( &x, 1 ) )`.
[endsect]
[section `constexpr bool ends_with( Ch const* x ) const noexcept;`]
* *Returns:* `ends_with( basic_string_view( x ) )`.
[endsect]
[endsect]
[endsect]
[section Searching]
[section find]
[section `constexpr size_type find( basic_string_view str, size_type pos = 0 ) const noexcept;`]
* *Returns:* The lowest position `i` such that `i >= pos` and `substr( i, str.size() ) == str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type find( Ch c, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type find( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `find( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type find( Ch const* s, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section rfind]
[section `constexpr size_type rfind( basic_string_view str, size_type pos = npos ) const noexcept;`]
* *Returns:* The highest position `i` such that `i <= pos` and `substr( i, str.size() ) == str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type rfind( Ch c, size_type pos = npos ) const noexcept;`]
* *Returns:* `rfind( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type rfind( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `rfind( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type rfind( Ch const* s, size_type pos = npos ) const noexcept;`]
* *Returns:* `rfind( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section find_first_of]
[section `constexpr size_type find_first_of( basic_string_view str, size_type pos = 0 ) const noexcept;`]
* *Returns:* The lowest position `i` such that `i >= pos` and the character at position `i` is equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type find_first_of( Ch c, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find_first_of( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type find_first_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `find_first_of( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type find_first_of( Ch const* s, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find_first_of( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section find_last_of]
[section `constexpr size_type find_last_of( basic_string_view str, size_type pos = npos ) const noexcept;`]
* *Returns:* The highest position `i` such that `i <= pos` and the character at position `i` is equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type find_last_of( Ch c, size_type pos = npos ) const noexcept;`]
* *Returns:* `find_last_of( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type find_last_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `find_last_of( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type find_last_of( Ch const* s, size_type pos = npos ) const noexcept;`]
* *Returns:* `find_last_of( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section find_first_not_of]
[section `constexpr size_type find_first_not_of( basic_string_view str, size_type pos = 0 ) const noexcept;`]
* *Returns:* The lowest position `i` such that `i >= pos` and the character at position `i` is not equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type find_first_not_of( Ch c, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find_first_not_of( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type find_first_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `find_first_not_of( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type find_first_not_of( Ch const* s, size_type pos = 0 ) const noexcept;`]
* *Returns:* `find_first_not_of( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section find_last_not_of]
[section `constexpr size_type find_last_not_of( basic_string_view str, size_type pos = npos ) const noexcept;`]
* *Returns:* The highest position `i` such that `i <= pos` and the character at position `i` is not equal to one of the characters in `str`, or `npos` if such a position doesn't exist.
[endsect]
[section `constexpr size_type find_last_not_of( Ch c, size_type pos = npos ) const noexcept;`]
* *Returns:* `find_last_not_of( basic_string_view( &c, 1 ), pos )`.
[endsect]
[section `constexpr size_type find_last_not_of( Ch const* s, size_type pos, size_type n ) const noexcept;`]
* *Returns:* `find_last_not_of( basic_string_view( s, n ), pos )`.
[endsect]
[section `constexpr size_type find_last_not_of( Ch const* s, size_type pos = npos ) const noexcept;`]
* *Returns:* `find_last_not_of( basic_string_view( s ), pos )`.
[endsect]
[endsect]
[section contains]
[section `constexpr bool contains( basic_string_view sv ) const noexcept;`]
* *Returns:* `find( sv ) != npos`.
[endsect]
[section `constexpr bool contains( Ch c ) const noexcept;`]
* *Returns:* `find( c ) != npos`.
[endsect]
[section `constexpr bool contains( Ch const* s ) const noexcept;`]
* *Returns:* `find( s ) != npos`.
[endsect]
[endsect]
[endsect]
[section Relational Operators]
[section `constexpr friend bool operator==( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) == 0`.
[endsect]
[section `constexpr friend bool operator!=( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) != 0`.
[endsect]
[section `constexpr friend bool operator<( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) < 0`.
[endsect]
[section `constexpr friend bool operator<=( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) <= 0`.
[endsect]
[section `constexpr friend bool operator>( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) > 0`.
[endsect]
[section `constexpr friend bool operator>=( basic_string_view sv1, basic_string_view sv2 ) noexcept;`]
* *Returns:* `sv1.compare( sv2 ) >= 0`.
[endsect]
[endsect]
[section Stream Inserter]
[section `template<class Ch> std::basic_ostream<Ch>& operator<<( std::basic_ostream<Ch>& os, basic_string_view<Ch> str );`]
* *Effects:* equivalent to `os << x`, where `x` is a pointer to a null-terminated character sequence with the same contents as `str`.
[endsect]
[endsect]
[endsect]
[endsect]

View File

@@ -22,13 +22,20 @@
#include <cstring>
#if defined(_MSC_VER)
# include <intrin.h>
# pragma intrinsic(_BitScanForward)
# pragma intrinsic(_BitScanReverse)
# if defined(_M_X64)
# pragma intrinsic(_BitScanForward64)
# pragma intrinsic(_BitScanReverse64)
# endif
# pragma warning(push)
# pragma warning(disable: 4127) // conditional expression is constant
# pragma warning(disable: 4244) // conversion from int to T
#endif // defined(_MSC_VER)
namespace boost
@@ -578,4 +585,8 @@ typedef endian::type endian_type;
} // namespace core
} // namespace boost
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // #ifndef BOOST_CORE_BIT_HPP_INCLUDED

File diff suppressed because it is too large Load Diff

View File

@@ -25,6 +25,11 @@ Distributed under the Boost Software License, Version 1.0.
#endif
#endif
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4510)
#endif
namespace boost {
template<class T>
@@ -143,4 +148,8 @@ BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t();
} /* boost */
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif

View File

@@ -11,7 +11,7 @@
//
// BOOST_TEST_TRAIT_TRUE, BOOST_TEST_TRAIT_FALSE, BOOST_TEST_TRAIT_SAME
//
// Copyright 2014 Peter Dimov
// Copyright 2014, 2021 Peter Dimov
//
// Copyright 2019 Glen Joseph Fernandes
// (glenjofe@gmail.com)
@@ -21,60 +21,15 @@
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/core/lightweight_test.hpp>
#include <boost/core/typeinfo.hpp>
#include <boost/core/type_name.hpp>
#include <boost/core/is_same.hpp>
#include <boost/config.hpp>
namespace boost
{
namespace detail
{
template<class, int = 0> struct test_print { };
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 2>)
{
return o << boost::core::demangled_name(BOOST_CORE_TYPEID(T));
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T, 1>)
{
return o << test_print<T, 2>();
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const T, 1>)
{
return o << test_print<T, 2>() << " const";
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<volatile T, 1>)
{
return o << test_print<T, 2>() << " volatile";
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<const volatile T, 1>)
{
return o << test_print<T, 2>() << " const volatile";
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T>)
{
return o << test_print<T, 1>();
}
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&>)
{
return o << test_print<T, 1>() << " &";
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T> inline std::ostream& operator<<(std::ostream& o, test_print<T&&>)
{
return o << test_print<T, 1>() << " &&";
}
#endif
template< class T > inline void test_trait_impl( char const * trait, void (*)( T ),
bool expected, char const * file, int line, char const * function )
{
@@ -86,7 +41,7 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): predicate '" << trait << "' ["
<< boost::core::demangled_name( BOOST_CORE_TYPEID(T) ) << "]"
<< boost::core::type_name<T>() << "]"
<< " test failed in function '" << function
<< "' (should have been " << ( expected? "true": "false" ) << ")"
<< std::endl;
@@ -112,8 +67,8 @@ template<class T1, class T2> inline void test_trait_same_impl( char const * type
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test 'is_same<" << types << ">'"
<< " failed in function '" << function
<< "' ('" << test_print<T1>()
<< "' != '" << test_print<T2>() << "')"
<< "' ('" << boost::core::type_name<T1>()
<< "' != '" << boost::core::type_name<T2>() << "')"
<< std::endl;
++test_results().errors();
@@ -121,7 +76,6 @@ template<class T1, class T2> inline void test_trait_same_impl( char const * type
}
} // namespace detail
} // namespace boost
#define BOOST_TEST_TRAIT_TRUE(type) ( ::boost::detail::test_trait_impl(#type, (void(*)type)0, true, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )

View File

@@ -56,6 +56,7 @@ struct noinit_adaptor
template<class U>
void destroy(U* p) {
p->~U();
(void)p;
}
};

407
include/boost/core/span.hpp Normal file
View File

@@ -0,0 +1,407 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_SPAN_HPP
#define BOOST_CORE_SPAN_HPP
#include <array>
#include <iterator>
#include <type_traits>
#include <cstddef>
namespace boost {
constexpr std::size_t dynamic_extent = static_cast<std::size_t>(-1);
template<class T, std::size_t E = dynamic_extent>
class span;
namespace detail {
template<class U, class T>
struct span_convertible {
static constexpr bool value = std::is_convertible<U(*)[], T(*)[]>::value;
};
template<std::size_t E, std::size_t N>
struct span_capacity {
static constexpr bool value = E == boost::dynamic_extent || E == N;
};
template<class T, std::size_t E, class U, std::size_t N>
struct span_compatible {
static constexpr bool value = span_capacity<E, N>::value &&
span_convertible<U, T>::value;
};
template<class T>
struct span_uncvref {
typedef typename std::remove_cv<typename
std::remove_reference<T>::type>::type type;
};
template<class>
struct span_is_span {
static constexpr bool value = false;
};
template<class T, std::size_t E>
struct span_is_span<boost::span<T, E> > {
static constexpr bool value = true;
};
template<class T>
struct span_is_array {
static constexpr bool value = false;
};
template<class T, std::size_t N>
struct span_is_array<std::array<T, N> > {
static constexpr bool value = true;
};
template<class, class = void>
struct span_data { };
template<class T>
struct span_data<T,
typename std::enable_if<std::is_pointer<decltype(std::declval<T
&>().data())>::value>::type> {
typedef typename std::remove_pointer<decltype(std::declval<T
&>().data())>::type type;
};
template<class, class, class = void>
struct span_has_data {
static constexpr bool value = false;
};
template<class R, class T>
struct span_has_data<R, T, typename std::enable_if<span_convertible<typename
span_data<R>::type, T>::value>::type> {
static constexpr bool value = true;
};
template<class, class = void>
struct span_has_size {
static constexpr bool value = false;
};
template<class R>
struct span_has_size<R, typename
std::enable_if<std::is_convertible<decltype(std::declval<R&>().size()),
std::size_t>::value>::type> {
static constexpr bool value = true;
};
template<class R, class T>
struct span_is_range {
static constexpr bool value = (std::is_const<T>::value ||
std::is_lvalue_reference<R>::value) &&
!span_is_span<typename span_uncvref<R>::type>::value &&
!span_is_array<typename span_uncvref<R>::type>::value &&
!std::is_array<typename span_uncvref<R>::type>::value &&
span_has_data<R, T>::value &&
span_has_size<R>::value;
};
template<std::size_t E, std::size_t N>
struct span_implicit {
static constexpr bool value = E == boost::dynamic_extent ||
N != boost::dynamic_extent;
};
template<class T, std::size_t E, class U, std::size_t N>
struct span_copyable {
static constexpr bool value = (N == boost::dynamic_extent ||
span_capacity<E, N>::value) && span_convertible<U, T>::value;
};
template<std::size_t E, std::size_t O>
struct span_sub {
static constexpr std::size_t value = E == boost::dynamic_extent ?
boost::dynamic_extent : E - O;
};
template<class T, std::size_t E>
struct span_store {
constexpr span_store(T* p_, std::size_t) noexcept
: p(p_) { }
static constexpr std::size_t n = E;
T* p;
};
template<class T>
struct span_store<T, boost::dynamic_extent> {
constexpr span_store(T* p_, std::size_t n_) noexcept
: p(p_)
, n(n_) { }
T* p;
std::size_t n;
};
template<class T, std::size_t E>
struct span_bytes {
static constexpr std::size_t value = sizeof(T) * E;
};
template<class T>
struct span_bytes<T, boost::dynamic_extent> {
static constexpr std::size_t value = boost::dynamic_extent;
};
} /* detail */
template<class T, std::size_t E>
class span {
public:
typedef T element_type;
typedef typename std::remove_cv<T>::type value_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T* iterator;
typedef const T* const_iterator;
typedef std::reverse_iterator<T*> reverse_iterator;
typedef std::reverse_iterator<const T*> const_reverse_iterator;
static constexpr std::size_t extent = E;
template<std::size_t N = E,
typename std::enable_if<N == dynamic_extent || N == 0, int>::type = 0>
constexpr span() noexcept
: s_(0, 0) { }
template<class I,
typename std::enable_if<E == dynamic_extent &&
detail::span_convertible<I, T>::value, int>::type = 0>
constexpr span(I* f, size_type c)
: s_(f, c) { }
template<class I,
typename std::enable_if<E != dynamic_extent &&
detail::span_convertible<I, T>::value, int>::type = 0>
explicit constexpr span(I* f, size_type c)
: s_(f, c) { }
template<class I, class L,
typename std::enable_if<E == dynamic_extent &&
detail::span_convertible<I, T>::value, int>::type = 0>
constexpr span(I* f, L* l)
: s_(f, l - f) { }
template<class I, class L,
typename std::enable_if<E != dynamic_extent &&
detail::span_convertible<I, T>::value, int>::type = 0>
explicit constexpr span(I* f, L* l)
: s_(f, l - f) { }
template<std::size_t N,
typename std::enable_if<detail::span_capacity<E, N>::value,
int>::type = 0>
constexpr span(typename std::enable_if<true, T>::type (&a)[N]) noexcept
: s_(a, N) { }
template<class U, std::size_t N,
typename std::enable_if<detail::span_compatible<T, E, U, N>::value,
int>::type = 0>
constexpr span(std::array<U, N>& a) noexcept
: s_(a.data(), N) { }
template<class U, std::size_t N,
typename std::enable_if<detail::span_compatible<T, E, const U,
N>::value, int>::type = 0>
constexpr span(const std::array<U, N>& a) noexcept
: s_(a.data(), N) { }
template<class R,
typename std::enable_if<E == dynamic_extent &&
detail::span_is_range<R, T>::value, int>::type = 0>
constexpr span(R&& r) noexcept(noexcept(r.data()) && noexcept(r.size()))
: s_(r.data(), r.size()) { }
template<class R,
typename std::enable_if<E != dynamic_extent &&
detail::span_is_range<R, T>::value, int>::type = 0>
explicit constexpr span(R&& r) noexcept(noexcept(r.data()) &&
noexcept(r.size()))
: s_(r.data(), r.size()) { }
template<class U, std::size_t N,
typename std::enable_if<detail::span_implicit<E, N>::value &&
detail::span_copyable<T, E, U, N>::value, int>::type = 0>
constexpr span(const span<U, N>& s) noexcept
: s_(s.data(), s.size()) { }
template<class U, std::size_t N,
typename std::enable_if<!detail::span_implicit<E, N>::value &&
detail::span_copyable<T, E, U, N>::value, int>::type = 0>
explicit constexpr span(const span<U, N>& s) noexcept
: s_(s.data(), s.size()) { }
template<std::size_t C>
constexpr span<T, C> first() const {
static_assert(C <= E, "Count <= Extent");
return span<T, C>(s_.p, C);
}
template<std::size_t C>
constexpr span<T, C> last() const {
static_assert(C <= E, "Count <= Extent");
return span<T, C>(s_.p + (s_.n - C), C);
}
template<std::size_t O, std::size_t C = dynamic_extent>
constexpr typename std::enable_if<C == dynamic_extent,
span<T, detail::span_sub<E, O>::value> >::type subspan() const {
static_assert(O <= E, "Offset <= Extent");
return span<T, detail::span_sub<E, O>::value>(s_.p + O, s_.n - O);
}
template<std::size_t O, std::size_t C = dynamic_extent>
constexpr typename std::enable_if<C != dynamic_extent,
span<T, C> >::type subspan() const {
static_assert(O <= E && C <= E - O,
"Offset <= Extent && Count <= Extent - Offset");
return span<T, C>(s_.p + O, C);
}
constexpr span<T, dynamic_extent> first(size_type c) const {
return span<T, dynamic_extent>(s_.p, c);
}
constexpr span<T, dynamic_extent> last(size_type c) const {
return span<T, dynamic_extent>(s_.p + (s_.n - c), c);
}
constexpr span<T, dynamic_extent> subspan(size_type o,
size_type c = dynamic_extent) const {
return span<T, dynamic_extent>(s_.p + o,
c == dynamic_extent ? s_.n - o : c);
}
constexpr size_type size() const noexcept {
return s_.n;
}
constexpr size_type size_bytes() const noexcept {
return s_.n * sizeof(T);
}
constexpr bool empty() const noexcept {
return s_.n == 0;
}
constexpr reference operator[](size_type i) const {
return s_.p[i];
}
constexpr reference front() const {
return *s_.p;
}
constexpr reference back() const {
return s_.p[s_.n - 1];
}
constexpr pointer data() const noexcept {
return s_.p;
}
constexpr iterator begin() const noexcept {
return s_.p;
}
constexpr iterator end() const noexcept {
return s_.p + s_.n;
}
constexpr reverse_iterator rbegin() const noexcept {
return reverse_iterator(s_.p + s_.n);
}
constexpr reverse_iterator rend() const noexcept {
return reverse_iterator(s_.p);
}
constexpr const_iterator cbegin() const noexcept {
return s_.p;
}
constexpr const_iterator cend() const noexcept {
return s_.p + s_.n;
}
constexpr const_reverse_iterator crbegin() const noexcept {
return const_reverse_iterator(s_.p + s_.n);
}
constexpr const_reverse_iterator crend() const noexcept {
return const_reverse_iterator(s_.p);
}
friend constexpr iterator begin(span s) noexcept {
return s.begin();
}
friend constexpr iterator end(span s) noexcept {
return s.end();
}
private:
detail::span_store<T, E> s_;
};
template<class T, std::size_t E>
constexpr std::size_t span<T, E>::extent;
#ifdef __cpp_deduction_guides
template<class I, class L>
span(I*, L) -> span<I>;
template<class T, std::size_t N>
span(T(&)[N]) -> span<T, N>;
template<class T, std::size_t N>
span(std::array<T, N>&) -> span<T, N>;
template<class T, std::size_t N>
span(const std::array<T, N>&) -> span<const T, N>;
template<class R>
span(R&&) -> span<typename detail::span_data<R>::type>;
template<class T, std::size_t E>
span(span<T, E>) -> span<T, E>;
#endif
#ifdef __cpp_lib_byte
template<class T, std::size_t E>
inline span<const std::byte, detail::span_bytes<T, E>::value>
as_bytes(span<T, E> s) noexcept
{
return span<const std::byte, detail::span_bytes<T,
E>::value>(reinterpret_cast<const std::byte*>(s.data()),
s.size_bytes());
}
template<class T, std::size_t E>
inline typename std::enable_if<!std::is_const<T>::value,
span<std::byte, detail::span_bytes<T, E>::value> >::type
as_writable_bytes(span<T, E> s) noexcept
{
return span<std::byte, detail::span_bytes<T,
E>::value>(reinterpret_cast<std::byte*>(s.data()), s.size_bytes());
}
#endif
} /* boost */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
# Copyright 2018, 2019 Peter Dimov
# Copyright 2018, 2019, 2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
@@ -6,7 +6,22 @@ include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(HAVE_BOOST_TEST)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::static_assert Boost::type_traits Boost::throw_exception)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::core Boost::static_assert)
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::type_traits)
boost_test(TYPE run SOURCES eif_constructors.cpp)
boost_test(TYPE run SOURCES eif_dummy_arg_disambiguation.cpp)
boost_test(TYPE run SOURCES eif_lazy.cpp)
boost_test(TYPE run SOURCES eif_lazy_test.cpp)
boost_test(TYPE run SOURCES eif_member_templates.cpp)
boost_test(TYPE run SOURCES eif_namespace_disambiguation.cpp)
boost_test(TYPE run SOURCES eif_no_disambiguation.cpp)
boost_test(TYPE run SOURCES eif_partial_specializations.cpp)
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::throw_exception)
boost_test(TYPE run SOURCES no_exceptions_support_test.cpp)
endif()

View File

@@ -1,6 +1,6 @@
# Boost.Core Library test Jamfile
#
# Copyright (c) 2014, 2017 Peter Dimov
# Copyright (c) 2014-2021 Peter Dimov
#
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at
@@ -9,6 +9,19 @@
import modules ;
import testing ;
project : requirements
<warnings>extra
<toolset>msvc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>gcc-4.4:<cxxflags>-Wno-sign-compare ;
local warning-as-errors-off =
"-<toolset>msvc:<warnings-as-errors>on"
"-<toolset>gcc:<warnings-as-errors>on"
"-<toolset>clang:<warnings-as-errors>on" ;
# quick test (for CI)
run quick.cpp ;
@@ -18,51 +31,64 @@ run addressof_test2.cpp ;
run addressof_np_test.cpp ;
run addressof_fn_test.cpp ;
compile addressof_constexpr_test.cpp ;
compile-fail addressof_fail_rvalue.cpp ;
compile-fail addressof_fail_rvalue.cpp
: $(warning-as-errors-off) ;
run checked_delete_test.cpp ;
compile-fail checked_delete_fail.cpp ;
compile-fail checked_delete_fail2.cpp ;
compile-fail checked_delete_fail.cpp
: $(warning-as-errors-off) ;
compile-fail checked_delete_fail2.cpp
: $(warning-as-errors-off) ;
compile ref_ct_test.cpp ;
run ref_test.cpp ;
run ref_ref_test.cpp ;
run ref_fn_test.cpp ;
compile-fail ref_rv_fail1.cpp ;
compile-fail ref_rv_fail2.cpp ;
compile-fail ref_rv_fail3.cpp ;
compile-fail ref_rv_fail4.cpp ;
compile-fail ref_rv_fail5.cpp ;
compile-fail ref_implicit_fail.cpp ;
compile-fail ref_implicit_fail2.cpp ;
compile-fail ref_implicit_fail3.cpp ;
compile-fail ref_implicit_fail4.cpp ;
compile-fail ref_rv_fail1.cpp
: $(warning-as-errors-off) ;
compile-fail ref_rv_fail2.cpp
: $(warning-as-errors-off) ;
compile-fail ref_rv_fail3.cpp
: $(warning-as-errors-off) ;
compile-fail ref_rv_fail4.cpp
: $(warning-as-errors-off) ;
compile-fail ref_rv_fail5.cpp
: $(warning-as-errors-off) ;
compile-fail ref_implicit_fail.cpp
: $(warning-as-errors-off) ;
compile-fail ref_implicit_fail2.cpp
: $(warning-as-errors-off) ;
compile-fail ref_implicit_fail3.cpp
: $(warning-as-errors-off) ;
compile-fail ref_implicit_fail4.cpp
: $(warning-as-errors-off) ;
run ref_cv_test.cpp ;
run ref_conversion_test.cpp ;
run eif_constructors.cpp ;
run eif_dummy_arg_disambiguation.cpp ;
run eif_lazy.cpp ;
run eif_lazy_test.cpp ;
run eif_member_templates.cpp ;
run eif_namespace_disambiguation.cpp ;
run eif_no_disambiguation.cpp ;
run eif_partial_specializations.cpp ;
run eif_constructors.cpp : ;
run eif_dummy_arg_disambiguation.cpp : ;
run eif_lazy.cpp : ;
run eif_lazy_test.cpp : ;
run eif_member_templates.cpp : ;
run eif_namespace_disambiguation.cpp : ;
run eif_no_disambiguation.cpp : ;
run eif_partial_specializations.cpp : ;
compile-fail noncopyable_compile_fail.cpp ;
compile-fail noncopyable_compile_fail.cpp
: $(warning-as-errors-off) ;
run explicit_operator_bool.cpp ;
run explicit_operator_bool_noexcept.cpp ;
compile-fail explicit_operator_bool_compile_fail_conv_int.cpp ;
compile-fail explicit_operator_bool_compile_fail_conv_pvoid.cpp ;
compile-fail explicit_operator_bool_compile_fail_delete.cpp ;
compile-fail explicit_operator_bool_compile_fail_shift.cpp ;
compile-fail explicit_operator_bool_compile_fail_conv_int.cpp
: $(warning-as-errors-off) ;
compile-fail explicit_operator_bool_compile_fail_conv_pvoid.cpp
: $(warning-as-errors-off) ;
compile-fail explicit_operator_bool_compile_fail_delete.cpp
: $(warning-as-errors-off) ;
compile-fail explicit_operator_bool_compile_fail_shift.cpp
: $(warning-as-errors-off) ;
compile ignore_unused_test.cpp
: <warnings>extra
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>msvc:<warnings-as-errors>on ;
compile ignore_unused_test.cpp ;
run sp_typeinfo_test.cpp ;
run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ;
@@ -112,9 +138,9 @@ run-fail lightweight_test_fail4.cpp ;
run-fail lightweight_test_fail5.cpp ;
run-fail lightweight_test_fail6.cpp ;
run-fail lightweight_test_fail7.cpp ;
run-fail lightweight_test_fail7.cpp : : : <rtti>off : lightweight_test_fail7_no_rtti ;
run-fail lightweight_test_fail7.cpp : : : <rtti>off <toolset>gcc-4.4:<build>no : lightweight_test_fail7_no_rtti ;
run-fail lightweight_test_fail8.cpp ;
run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_rtti ;
run-fail lightweight_test_fail8.cpp : : : <rtti>off <toolset>gcc-4.4:<build>no : lightweight_test_fail8_no_rtti ;
run-fail lightweight_test_fail9.cpp ;
run-fail lightweight_test_fail10.cpp ;
run-fail lightweight_test_fail11.cpp : ;
@@ -151,8 +177,10 @@ run demangled_name_test.cpp
run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output : demangled_name_test_no_rtti ;
run scoped_enum.cpp ;
compile-fail scoped_enum_compile_fail_conv_from_int.cpp ;
compile-fail scoped_enum_compile_fail_conv_to_int.cpp ;
compile-fail scoped_enum_compile_fail_conv_from_int.cpp
: $(warning-as-errors-off) ;
compile-fail scoped_enum_compile_fail_conv_to_int.cpp
: $(warning-as-errors-off) ;
run underlying_type.cpp ;
@@ -228,7 +256,7 @@ run uncaught_exceptions.cpp
run uncaught_exceptions_np.cpp
: : : <exception-handling>on ;
run no_exceptions_support_test.cpp ;
run no_exceptions_support_test.cpp : ;
run no_exceptions_support_test.cpp : : : <exception-handling>off : no_exceptions_support_test_nx ;
run cmath_test.cpp ;
@@ -247,5 +275,38 @@ run bit_endian_test.cpp ;
run type_name_test.cpp ;
run sv_types_test.cpp ;
run sv_construct_test.cpp ;
run sv_iteration_test.cpp ;
run sv_element_access_test.cpp ;
run sv_modifiers_test.cpp ;
run sv_copy_test.cpp ;
run sv_substr_test.cpp ;
run sv_compare_test.cpp ;
run sv_starts_with_test.cpp ;
run sv_ends_with_test.cpp ;
run sv_find_test.cpp ;
run sv_rfind_test.cpp ;
run sv_find_first_of_test.cpp
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
run sv_find_last_of_test.cpp
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
run sv_find_first_not_of_test.cpp
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
run sv_find_last_not_of_test.cpp
: : : <toolset>gcc-4.4:<cxxflags>-Wno-type-limits ;
run sv_contains_test.cpp ;
run sv_eq_test.cpp ;
run sv_lt_test.cpp ;
run sv_stream_insert_test.cpp ;
run sv_conversion_test.cpp ;
run span_test.cpp ;
run span_types_test.cpp ;
run span_constructible_test.cpp ;
run span_deduction_guide_test.cpp ;
run as_bytes_test.cpp ;
run as_writable_bytes_test.cpp ;
use-project /boost/core/swap : ./swap ;
build-project ./swap ;

View File

@@ -10,6 +10,10 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/alloc_construct.hpp>
#include <boost/core/lightweight_test.hpp>
#if defined(_MSC_VER)
# pragma warning(disable: 4100) // unreferenced parameter 'ptr'
#endif
class type {
public:
explicit type(int x)

42
test/as_bytes_test.cpp Normal file
View File

@@ -0,0 +1,42 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <cstddef>
#ifdef __cpp_lib_byte
#include <boost/core/span.hpp>
#include <boost/core/lightweight_test.hpp>
void test_dynamic()
{
int a[4];
boost::span<const std::byte> s =
boost::as_bytes(boost::span<int>(&a[0], 4));
BOOST_TEST_EQ(s.data(), reinterpret_cast<const std::byte*>(&a[0]));
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
}
void test_static()
{
int a[4];
boost::span<const std::byte, sizeof(int) * 4> s =
boost::as_bytes(boost::span<int, 4>(&a[0], 4));
BOOST_TEST_EQ(s.data(), reinterpret_cast<const std::byte*>(&a[0]));
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
}
int main()
{
test_dynamic();
test_static();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,42 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <cstddef>
#ifdef __cpp_lib_byte
#include <boost/core/span.hpp>
#include <boost/core/lightweight_test.hpp>
void test_dynamic()
{
int a[4];
boost::span<std::byte> s =
boost::as_writable_bytes(boost::span<int>(&a[0], 4));
BOOST_TEST_EQ(s.data(), reinterpret_cast<std::byte*>(&a[0]));
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
}
void test_static()
{
int a[4];
boost::span<std::byte, sizeof(int) * 4> s =
boost::as_writable_bytes(boost::span<int, 4>(&a[0], 4));
BOOST_TEST_EQ(s.data(), reinterpret_cast<std::byte*>(&a[0]));
BOOST_TEST_EQ(s.size(), sizeof(int) * 4);
}
int main()
{
test_dynamic();
test_static();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -9,6 +9,10 @@
#include <boost/cstdint.hpp>
#include <cstring>
#if defined(_MSC_VER)
# pragma warning(disable: 4127) // conditional expression is constant
#endif
int main()
{
boost::uint64_t v = static_cast<boost::uint64_t>( 0x0102030405060708ull );

View File

@@ -1,4 +1,4 @@
# Copyright 2018, 2019 Peter Dimov
# Copyright 2018, 2019, 2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
@@ -9,6 +9,8 @@ project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/core)
add_subdirectory(../../../assert boostorg/assert)
add_subdirectory(../../../config boostorg/config)
add_subdirectory(../../../static_assert boostorg/static_assert)
add_subdirectory(../../../throw_exception boostorg/throw_exception)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::core)

View File

@@ -13,6 +13,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
using boost::enable_if;
using boost::disable_if;
@@ -39,7 +40,7 @@ struct xstring
disable_if<is_arithmetic<It> >::type* = 0)
: data(end-begin) {}
int data;
std::ptrdiff_t data;
};
@@ -58,4 +59,3 @@ int main()
return boost::report_errors();
}

View File

@@ -24,11 +24,11 @@ template <int N> struct dummy {
template<class T>
typename enable_if<is_arithmetic<T>, bool>::type
arithmetic_object(T t, dummy<0> = 0) { return true; }
arithmetic_object(T /*t*/, dummy<0> = 0) { return true; }
template<class T>
typename disable_if<is_arithmetic<T>, bool>::type
arithmetic_object(T t, dummy<1> = 0) { return false; }
arithmetic_object(T /*t*/, dummy<1> = 0) { return false; }
int main()
@@ -42,4 +42,3 @@ int main()
return boost::report_errors();
}

View File

@@ -60,21 +60,21 @@ namespace A {
template<class T>
typename lazy_enable_if<is_int_or_double<T>, some_traits<T> >::type
foo(T t) { return true; }
foo(T /*t*/) { return true; }
template<class T>
typename lazy_enable_if_c<is_int_or_double<T>::value, some_traits<T> >::type
foo2(T t) { return true; }
foo2(T /*t*/) { return true; }
}
namespace B {
template<class T>
typename lazy_disable_if<is_int_or_double<T>, make_bool<T> >::type
foo(T t) { return false; }
foo(T /*t*/) { return false; }
template<class T>
typename lazy_disable_if_c<is_int_or_double<T>::value, make_bool<T> >::type
foo2(T t) { return false; }
foo2(T /*t*/) { return false; }
}
int main()
@@ -95,4 +95,3 @@ int main()
return boost::report_errors();
}

View File

@@ -26,13 +26,13 @@ template<class T> struct not_
namespace A {
template<class T>
typename enable_if<is_arithmetic<T>, bool>::type
arithmetic_object(T t) { return true; }
arithmetic_object(T /*t*/) { return true; }
}
namespace B {
template<class T>
typename enable_if<not_<is_arithmetic<T> >, bool>::type
arithmetic_object(T t) { return false; }
arithmetic_object(T /*t*/) { return false; }
}
int main()
@@ -47,4 +47,3 @@ int main()
return boost::report_errors();
}

View File

@@ -25,11 +25,11 @@ template<class T> struct not_
template<class T>
typename enable_if<is_arithmetic<T>, bool>::type
arithmetic_object(T t) { return true; }
arithmetic_object(T /*t*/) { return true; }
template<class T>
typename enable_if<not_<is_arithmetic<T> >, bool>::type
arithmetic_object(T t) { return false; }
arithmetic_object(T /*t*/) { return false; }
int main()
@@ -43,4 +43,3 @@ int main()
return boost::report_errors();
}

View File

@@ -76,6 +76,11 @@ int main(int, char*[])
BOOST_TEST(noexcept(static_cast< bool >(noexcept_val1)));
BOOST_TEST(noexcept(static_cast< bool >(noexcept_val2)));
(void)val1;
(void)val2;
(void)noexcept_val1;
(void)noexcept_val2;
return boost::report_errors();
}

View File

@@ -8,6 +8,10 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // std::auto_ptr
#endif
#include <boost/get_pointer.hpp>
#include <boost/core/lightweight_test.hpp>
#include <memory>

View File

@@ -8,6 +8,8 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#define _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
#include <boost/iterator.hpp>
#include <boost/core/is_same.hpp>
#include <boost/core/lightweight_test_trait.hpp>

View File

@@ -8,6 +8,10 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#if defined(__clang__)
# pragma clang diagnostic ignored "-Wstring-plus-int"
#endif
#include <boost/core/lightweight_test.hpp>
int main()

View File

@@ -8,6 +8,10 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
#include <boost/core/lightweight_test.hpp>
struct X

View File

@@ -8,6 +8,12 @@
// http://www.boost.org/LICENSE_1_0.txt
//
#if defined(_MSC_VER)
# pragma warning(disable: 4530) // C++ exception handler used
# pragma warning(disable: 4577) // noexcept used without /EHsc
# pragma warning(disable: 4702) // unreachable code
#endif
#include <boost/core/no_exceptions_support.hpp>
#include <boost/core/quick_exit.hpp>
#include <boost/throw_exception.hpp>

View File

@@ -1,4 +1,3 @@
// Test for quick_exit.hpp
//
// Copyright 2018 Peter Dimov
@@ -7,6 +6,9 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
#include <boost/core/quick_exit.hpp>

View File

@@ -1,4 +1,3 @@
// Test for quick_exit.hpp
//
// Copyright 2018 Peter Dimov
@@ -7,6 +6,9 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#if defined(_MSC_VER)
# pragma warning(disable: 4702) // unreachable code
#endif
#include <boost/core/quick_exit.hpp>

View File

@@ -21,10 +21,16 @@ void ref_test(boost::reference_wrapper<U>)
BOOST_STATIC_ASSERT((boost::core::is_same<T,type>::value));
}
template< typename T >
void assignable_test_(T x1, T x2)
{
x1 = x2;
}
template< typename T >
void assignable_test(T x)
{
x = x;
assignable_test_( x, x );
}
template< bool R, typename T >

View File

@@ -15,6 +15,10 @@
#include <boost/core/scoped_enum.hpp>
#include <boost/core/lightweight_test.hpp>
#if defined(_MSC_VER)
# pragma warning(disable: 4244) // conversion from enum_type to underlying_type
#endif
BOOST_SCOPED_ENUM_DECLARE_BEGIN(namespace_enum1)
{
value0,
@@ -142,6 +146,7 @@ void check_underlying_type()
// The real check for the type is in the underlying_type trait test.
namespace_enum2 enum1 = namespace_enum2::value1;
BOOST_TEST(sizeof(enum1) == sizeof(unsigned char));
(void)enum1;
}
int main(int, char*[])

View File

@@ -0,0 +1,200 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
#include <boost/core/span.hpp>
#include <boost/core/lightweight_test_trait.hpp>
template<class T>
struct range {
T* data() {
return 0;
}
const T* data() const {
return 0;
}
std::size_t size() const {
return 0;
}
};
struct base { };
struct derived
: base { };
void test_default()
{
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<
boost::span<int> >));
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<
boost::span<int, 0> >));
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<
boost::span<int, 2> >));
}
void test_data_size()
{
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
int*, std::size_t>));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
int*, std::size_t>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
int, std::size_t>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
const int*, std::size_t>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base>,
derived*, std::size_t>));
}
void test_first_last()
{
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
int*, int*>));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
int*, const int*>));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
int*, int*>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
int, int*>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
const int*, int*>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base>,
derived*, derived*>));
}
void test_array()
{
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
int(&)[4]>));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int, 4>,
int(&)[4]>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 2>,
int(&)[4]>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 4>,
int(&)[2]>));
}
void test_std_array()
{
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
std::array<int, 4>&>));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
std::array<int, 4>&>));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int, 4>,
std::array<int, 4>&>));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int,
4>, std::array<int, 4>&>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
std::array<const int, 4>&>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base>,
std::array<derived, 4>&>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 2>,
std::array<int, 4>&>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 4>,
std::array<const int, 4>&>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base, 4>,
std::array<derived, 4>&>));
}
void test_const_std_array()
{
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
const std::array<int, 4> >));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int,
4>, const std::array<int, 4> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
const std::array<int, 4> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<const
base>, const std::array<derived, 4> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<const int,
2>, const std::array<int, 4> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 4>,
const std::array<int, 4> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<const
base, 4>, const std::array<derived, 4> >));
}
void test_range()
{
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
range<int>&>));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
range<int>&>));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
range<int> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
int*>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
range<int> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
const range<int>&>));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base>,
range<derived>&>));
}
void test_span()
{
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
boost::span<int> >));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int>,
boost::span<int, 4> >));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<int, 4>,
boost::span<int> >));
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int,
4>, boost::span<int, 4> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
boost::span<const int> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base>,
boost::span<derived> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 2>,
boost::span<int, 4> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int, 4>,
boost::span<const int, 4> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base, 4>,
boost::span<derived, 4> >));
}
void test_copy()
{
BOOST_TEST_TRAIT_TRUE((std::is_copy_constructible<
boost::span<int> >));
BOOST_TEST_TRAIT_TRUE((std::is_copy_constructible<
boost::span<int, 4> >));
}
void test_assign()
{
BOOST_TEST_TRAIT_TRUE((std::is_copy_assignable<
boost::span<int> >));
BOOST_TEST_TRAIT_TRUE((std::is_copy_assignable<
boost::span<int, 4> >));
}
int main()
{
test_default();
test_data_size();
test_first_last();
test_array();
test_std_array();
test_const_std_array();
test_range();
test_span();
test_copy();
test_assign();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,116 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifdef __cpp_deduction_guides
#include <boost/core/span.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T>
class range {
public:
T* data() {
return &v_[0];
}
std::size_t size() const {
return 4;
}
private:
T v_[4];
};
void test_data_size()
{
int a[4];
boost::span s(&a[0], 4);
BOOST_TEST_EQ(s.extent, boost::dynamic_extent);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_first_last()
{
int a[4];
boost::span s(&a[0], &a[4]);
BOOST_TEST_EQ(s.extent, boost::dynamic_extent);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_array()
{
int a[4];
boost::span s(a);
BOOST_TEST_EQ(s.extent, 4);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_std_array()
{
std::array<int, 4> a;
boost::span s(a);
BOOST_TEST_EQ(s.extent, 4);
BOOST_TEST_EQ(s.data(), a.data());
BOOST_TEST_EQ(s.size(), a.size());
}
void test_const_std_array()
{
const std::array<int, 4> a = std::array<int, 4>();
boost::span s(a);
BOOST_TEST_EQ(s.extent, 4);
BOOST_TEST_EQ(s.data(), a.data());
BOOST_TEST_EQ(s.size(), a.size());
}
void test_range()
{
range<int> c;
boost::span s(c);
BOOST_TEST_EQ(s.extent, boost::dynamic_extent);
BOOST_TEST_EQ(s.data(), c.data());
BOOST_TEST_EQ(s.size(), c.size());
}
void test_span_dynamic()
{
int a[4];
boost::span s(boost::span<int>(&a[0], 4));
BOOST_TEST_EQ(s.extent, boost::dynamic_extent);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_span_static()
{
int a[4];
boost::span s(boost::span<int, 4>(&a[0], 4));
BOOST_TEST_EQ(s.extent, 4);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
int main()
{
test_data_size();
test_first_last();
test_array();
test_std_array();
test_const_std_array();
test_range();
test_span_dynamic();
test_span_static();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

433
test/span_test.cpp Normal file
View File

@@ -0,0 +1,433 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
#include <boost/core/span.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T>
class range {
public:
T* data() {
return &v_[0];
}
std::size_t size() const {
return 4;
}
private:
T v_[4];
};
void test_extent()
{
BOOST_TEST_EQ(boost::span<int>::extent,
boost::dynamic_extent);
BOOST_TEST_EQ((boost::span<int, 2>::extent), 2);
}
void test_default_construct_dynamic()
{
boost::span<int> s;
BOOST_TEST_EQ(s.data(), static_cast<int*>(0));
BOOST_TEST_EQ(s.size(), 0);
}
void test_default_construct_static()
{
boost::span<int, 0> s;
BOOST_TEST_EQ(s.data(), static_cast<int*>(0));
BOOST_TEST_EQ(s.size(), 0);
}
void test_construct_data_size()
{
int a[4];
boost::span<int> s(&a[0], 4);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_construct_first_last()
{
int a[4];
boost::span<int> s(&a[0], &a[4]);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_construct_array_dynamic()
{
int a[4];
boost::span<int> s(a);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_construct_array_static()
{
int a[4];
boost::span<int, 4> s(a);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_construct_std_array_dynamic()
{
std::array<int, 4> a;
boost::span<int> s(a);
BOOST_TEST_EQ(s.data(), a.data());
BOOST_TEST_EQ(s.size(), a.size());
}
void test_construct_std_array_static()
{
std::array<int, 4> a;
boost::span<int, 4> s(a);
BOOST_TEST_EQ(s.data(), a.data());
BOOST_TEST_EQ(s.size(), a.size());
}
void test_construct_const_std_array_dynamic()
{
const std::array<int, 4> a = std::array<int, 4>();
boost::span<const int> s(a);
BOOST_TEST_EQ(s.data(), a.data());
BOOST_TEST_EQ(s.size(), a.size());
}
void test_construct_const_std_array_static()
{
const std::array<int, 4> a = std::array<int, 4>();
boost::span<const int, 4> s(a);
BOOST_TEST_EQ(s.data(), a.data());
BOOST_TEST_EQ(s.size(), a.size());
}
void test_construct_range()
{
range<int> c;
boost::span<int> s(c);
BOOST_TEST_EQ(s.data(), c.data());
BOOST_TEST_EQ(s.size(), c.size());
}
void test_construct_span_dynamic()
{
int a[4];
boost::span<const int> s(boost::span<int>(&a[0], 4));
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_construct_span_dynamic_static()
{
int a[4];
boost::span<int> s(boost::span<int, 4>(&a[0], 4));
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_construct_span_static()
{
int a[4];
boost::span<const int, 4> s(boost::span<int, 4>(&a[0], 4));
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_construct_span_static_dynamic()
{
int a[4];
boost::span<int, 4> s(boost::span<int>(&a[0], 4));
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_copy_dynamic()
{
int a[4];
boost::span<int> s1(&a[0], 4);
boost::span<int> s2(s1);
BOOST_TEST_EQ(s2.data(), &a[0]);
BOOST_TEST_EQ(s2.size(), 4);
}
void test_copy_static()
{
int a[4];
boost::span<int, 4> s1(&a[0], 4);
boost::span<int, 4> s2(s1);
BOOST_TEST_EQ(s2.data(), &a[0]);
BOOST_TEST_EQ(s2.size(), 4);
}
void test_assign_dynamic()
{
boost::span<int> s;
int a[4];
s = boost::span<int>(&a[0], 4);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_assign_static()
{
int a1[4];
boost::span<int, 4> s(&a1[0], 4);
int a2[4];
s = boost::span<int, 4>(&a2[0], 4);
BOOST_TEST_EQ(s.data(), &a2[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_first()
{
int a[4];
boost::span<int, 2> s = boost::span<int>(&a[0],
4).first<2>();
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 2);
}
void test_last()
{
int a[4];
boost::span<int, 2> s = boost::span<int>(&a[0], 4).last<2>();
BOOST_TEST_EQ(s.data(), &a[2]);
BOOST_TEST_EQ(s.size(), 2);
}
void test_subspan_dynamic()
{
int a[4];
boost::span<int> s = boost::span<int>(&a[0], 4).subspan<2>();
BOOST_TEST_EQ(s.data(), &a[2]);
BOOST_TEST_EQ(s.size(), 2);
}
void test_subspan_static()
{
int a[4];
boost::span<int, 2> s = boost::span<int, 4>(&a[0],
4).subspan<2>();
BOOST_TEST_EQ(s.data(), &a[2]);
BOOST_TEST_EQ(s.size(), 2);
}
void test_subspan()
{
int a[4];
boost::span<int, 1> s = boost::span<int>(&a[0],
4).subspan<2, 1>();
BOOST_TEST_EQ(s.data(), &a[2]);
BOOST_TEST_EQ(s.size(), 1);
}
void test_first_size()
{
int a[4];
boost::span<int> s = boost::span<int>(&a[0], 4).first(2);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 2);
}
void test_last_size()
{
int a[4];
boost::span<int> s = boost::span<int>(&a[0], 4).last(2);
BOOST_TEST_EQ(s.data(), &a[2]);
BOOST_TEST_EQ(s.size(), 2);
}
void test_subspan_range()
{
int a[4];
boost::span<int> s = boost::span<int>(&a[0], 4).subspan(2);
BOOST_TEST_EQ(s.data(), &a[2]);
BOOST_TEST_EQ(s.size(), 2);
}
void test_subspan_range_count()
{
int a[4];
boost::span<int> s = boost::span<int>(&a[0],
4).subspan(2, 1);
BOOST_TEST_EQ(s.data(), &a[2]);
BOOST_TEST_EQ(s.size(), 1);
}
void test_size()
{
int a[4];
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).size()), 4);
}
void test_size_bytes()
{
int a[4];
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).size_bytes()),
4 * sizeof(int));
}
void test_empty_dynamic()
{
int a[4];
BOOST_TEST(boost::span<int>().empty());
BOOST_TEST_NOT((boost::span<int>(&a[0], 4).empty()));
}
void test_empty_static()
{
int a[4];
BOOST_TEST((boost::span<int, 0>().empty()));
BOOST_TEST_NOT((boost::span<int, 4>(&a[0], 4).empty()));
}
void test_index()
{
int a[4] = { 1, 2, 3, 4 };
BOOST_TEST_EQ((boost::span<int>(&a[0], 4)[2]), 3);
}
void test_front()
{
int a[4] = { 1, 2, 3, 4 };
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).front()), 1);
}
void test_back()
{
int a[4] = { 1, 2, 3, 4 };
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).back()), 4);
}
void test_data()
{
int a[4];
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).data()), &a[0]);
}
void test_begin()
{
int a[4];
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).begin()), &a[0]);
}
void test_end()
{
int a[4];
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).end()), &a[4]);
}
void test_rbegin()
{
int a[4];
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).rbegin().base()), &a[4]);
}
void test_rend()
{
int a[4];
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).rend().base()), &a[0]);
}
void test_cbegin()
{
int a[4];
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).cbegin()), &a[0]);
}
void test_cend()
{
int a[4];
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).cend()), &a[4]);
}
void test_crbegin()
{
int a[4];
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).crbegin().base()), &a[4]);
}
void test_crend()
{
int a[4];
BOOST_TEST_EQ((boost::span<int>(&a[0], 4).crend().base()), &a[0]);
}
void test_begin_span()
{
int a[4];
BOOST_TEST_EQ((begin(boost::span<int>(&a[0], 4))), &a[0]);
}
void test_end_span()
{
int a[4];
BOOST_TEST_EQ((end(boost::span<int>(&a[0], 4))), &a[4]);
}
int main()
{
test_extent();
test_default_construct_dynamic();
test_default_construct_static();
test_construct_data_size();
test_construct_first_last();
test_construct_array_dynamic();
test_construct_array_static();
test_construct_std_array_dynamic();
test_construct_std_array_static();
test_construct_const_std_array_dynamic();
test_construct_const_std_array_static();
test_construct_range();
test_construct_span_dynamic();
test_construct_span_dynamic_static();
test_construct_span_static();
test_construct_span_static_dynamic();
test_copy_dynamic();
test_copy_static();
test_assign_dynamic();
test_assign_static();
test_first();
test_last();
test_subspan_dynamic();
test_subspan_static();
test_subspan();
test_first_size();
test_last_size();
test_subspan_range();
test_subspan_range_count();
test_size();
test_size_bytes();
test_empty_dynamic();
test_empty_static();
test_index();
test_front();
test_back();
test_data();
test_begin();
test_end();
test_rbegin();
test_rend();
test_cbegin();
test_cend();
test_crbegin();
test_crend();
test_begin_span();
test_end_span();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

136
test/span_types_test.cpp Normal file
View File

@@ -0,0 +1,136 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
#include <boost/core/span.hpp>
#include <boost/core/lightweight_test_trait.hpp>
void test_element_type()
{
BOOST_TEST_TRAIT_SAME(int,
boost::span<int>::element_type);
BOOST_TEST_TRAIT_SAME(char,
boost::span<char>::element_type);
}
void test_value_type()
{
BOOST_TEST_TRAIT_SAME(char,
boost::span<char>::value_type);
BOOST_TEST_TRAIT_SAME(int,
boost::span<int>::value_type);
BOOST_TEST_TRAIT_SAME(int,
boost::span<const int>::value_type);
BOOST_TEST_TRAIT_SAME(int,
boost::span<volatile int>::value_type);
BOOST_TEST_TRAIT_SAME(int,
boost::span<const volatile int>::value_type);
}
void test_size_type()
{
BOOST_TEST_TRAIT_SAME(std::size_t,
boost::span<char>::size_type);
BOOST_TEST_TRAIT_SAME(std::size_t,
boost::span<int>::size_type);
}
void test_difference_type()
{
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
boost::span<char>::difference_type);
BOOST_TEST_TRAIT_SAME(std::ptrdiff_t,
boost::span<int>::difference_type);
}
void test_pointer()
{
BOOST_TEST_TRAIT_SAME(char*,
boost::span<char>::pointer);
BOOST_TEST_TRAIT_SAME(int*,
boost::span<int>::pointer);
}
void test_const_pointer()
{
BOOST_TEST_TRAIT_SAME(const char*,
boost::span<char>::const_pointer);
BOOST_TEST_TRAIT_SAME(const int*,
boost::span<int>::const_pointer);
}
void test_reference()
{
BOOST_TEST_TRAIT_SAME(char&,
boost::span<char>::reference);
BOOST_TEST_TRAIT_SAME(int&,
boost::span<int>::reference);
}
void test_const_reference()
{
BOOST_TEST_TRAIT_SAME(const char&,
boost::span<char>::const_reference);
BOOST_TEST_TRAIT_SAME(const int&,
boost::span<int>::const_reference);
}
void test_iterator()
{
BOOST_TEST_TRAIT_SAME(char*,
boost::span<char>::iterator);
BOOST_TEST_TRAIT_SAME(int*,
boost::span<int>::iterator);
}
void test_const_iterator()
{
BOOST_TEST_TRAIT_SAME(const char*,
boost::span<char>::const_iterator);
BOOST_TEST_TRAIT_SAME(const int*,
boost::span<int>::const_iterator);
}
void test_reverse_iterator()
{
BOOST_TEST_TRAIT_SAME(std::reverse_iterator<char*>,
boost::span<char>::reverse_iterator);
BOOST_TEST_TRAIT_SAME(std::reverse_iterator<int*>,
boost::span<int>::reverse_iterator);
}
void test_const_reverse_iterator()
{
BOOST_TEST_TRAIT_SAME(std::reverse_iterator<const char*>,
boost::span<char>::const_reverse_iterator);
BOOST_TEST_TRAIT_SAME(std::reverse_iterator<const int*>,
boost::span<int>::const_reverse_iterator);
}
int main()
{
test_element_type();
test_value_type();
test_size_type();
test_difference_type();
test_pointer();
test_const_pointer();
test_reference();
test_const_reference();
test_iterator();
test_const_iterator();
test_reverse_iterator();
test_const_reverse_iterator();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

145
test/sv_compare_test.cpp Normal file
View File

@@ -0,0 +1,145 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept>
#include <cstddef>
int main()
{
std::size_t const npos = boost::core::string_view::npos;
{
boost::core::string_view sv1( "" );
boost::core::string_view sv2( "" );
BOOST_TEST_EQ( sv1.compare( sv2 ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 0, sv2 ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 1, sv2 ), 0 );
BOOST_TEST_THROWS( sv1.compare( 1, 0, sv2 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 1, 1, sv2 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 1, npos, sv2 ), std::out_of_range );
BOOST_TEST_EQ( sv1.compare( 0, 0, sv2, 0, 0 ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 1, sv2, 0, 1 ), 0 );
BOOST_TEST_THROWS( sv1.compare( 1, 0, sv2, 0, 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 1, 1, sv2, 0, 1 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 0, 0, sv2, 1, 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 0, 1, sv2, 1, 1 ), std::out_of_range );
BOOST_TEST_EQ( sv1.compare( "" ), 0 );
BOOST_TEST_LT( sv1.compare( "1" ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 0, "" ), 0 );
BOOST_TEST_LT( sv1.compare( 0, 0, "1" ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 1, "" ), 0 );
BOOST_TEST_LT( sv1.compare( 0, 1, "1" ), 0 );
BOOST_TEST_THROWS( sv1.compare( 1, 0, "" ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 1, 1, "1" ), std::out_of_range );
BOOST_TEST_EQ( sv1.compare( 0, 0, "", 0 ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 0, "1", 0 ), 0 );
BOOST_TEST_LT( sv1.compare( 0, 0, "1", 1 ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 1, "", 0 ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 1, "1", 0 ), 0 );
BOOST_TEST_LT( sv1.compare( 0, 1, "1", 1 ), 0 );
BOOST_TEST_THROWS( sv1.compare( 1, 0, "", 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 1, 1, "1", 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 1, 1, "1", 1 ), std::out_of_range );
}
{
boost::core::string_view sv1( "123412345" );
boost::core::string_view sv2( "1234" );
BOOST_TEST_GT( sv1.compare( sv2 ), 0 );
BOOST_TEST_LT( sv1.compare( 0, 3, sv2 ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 4, sv2 ), 0 );
BOOST_TEST_GT( sv1.compare( 0, 5, sv2 ), 0 );
BOOST_TEST_GT( sv1.compare( 0, npos, sv2 ), 0 );
BOOST_TEST_LT( sv1.compare( 1, 0, sv2 ), 0 );
BOOST_TEST_GT( sv1.compare( 1, 1, sv2 ), 0 );
BOOST_TEST_LT( sv1.compare( 4, 3, sv2 ), 0 );
BOOST_TEST_EQ( sv1.compare( 4, 4, sv2 ), 0 );
BOOST_TEST_GT( sv1.compare( 4, 5, sv2 ), 0 );
BOOST_TEST_LT( sv1.compare( 9, 0, sv2 ), 0 );
BOOST_TEST_LT( sv1.compare( 9, 1, sv2 ), 0 );
BOOST_TEST_THROWS( sv1.compare( 10, 0, sv2 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 10, 1, sv2 ), std::out_of_range );
BOOST_TEST_GT( sv1.compare( 0, 3, sv2, 0, 2 ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 3, sv2, 0, 3 ), 0 );
BOOST_TEST_LT( sv1.compare( 0, 3, sv2, 0, 4 ), 0 );
BOOST_TEST_LT( sv1.compare( 0, 3, sv2, 0, 5 ), 0 );
BOOST_TEST_GT( sv1.compare( 0, 4, sv2, 0, 3 ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 4, sv2, 0, 4 ), 0 );
BOOST_TEST_EQ( sv1.compare( 0, 4, sv2, 0, 5 ), 0 );
BOOST_TEST_LT( sv1.compare( 5, 2, sv2, 1, npos ), 0 );
BOOST_TEST_EQ( sv1.compare( 5, 3, sv2, 1, npos ), 0 );
BOOST_TEST_GT( sv1.compare( 5, 4, sv2, 1, npos ), 0 );
BOOST_TEST_EQ( sv1.compare( 9, 0, sv2, 0, 0 ), 0 );
BOOST_TEST_LT( sv1.compare( 9, 1, sv2, 0, 1 ), 0 );
BOOST_TEST_THROWS( sv1.compare( 10, 0, sv2, 0, 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 10, 1, sv2, 0, 1 ), std::out_of_range );
BOOST_TEST_EQ( sv1.compare( 0, 0, sv2, 4, 0 ), 0 );
BOOST_TEST_GT( sv1.compare( 0, 1, sv2, 4, 1 ), 0 );
BOOST_TEST_THROWS( sv1.compare( 0, 0, sv2, 5, 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 0, 1, sv2, 5, 1 ), std::out_of_range );
BOOST_TEST_GT( sv1.compare( "" ), 0 );
BOOST_TEST_GT( sv1.compare( "12341234" ), 0 );
BOOST_TEST_GT( sv1.compare( "123412344" ), 0 );
BOOST_TEST_EQ( sv1.compare( "123412345" ), 0 );
BOOST_TEST_LT( sv1.compare( "123412346" ), 0 );
BOOST_TEST_LT( sv1.compare( "1234123456" ), 0 );
BOOST_TEST_GT( sv1.compare( 4, 3, "" ), 0 );
BOOST_TEST_GT( sv1.compare( 4, 3, "1" ), 0 );
BOOST_TEST_GT( sv1.compare( 4, 3, "12" ), 0 );
BOOST_TEST_GT( sv1.compare( 4, 3, "122" ), 0 );
BOOST_TEST_EQ( sv1.compare( 4, 3, "123" ), 0 );
BOOST_TEST_LT( sv1.compare( 4, 3, "124" ), 0 );
BOOST_TEST_LT( sv1.compare( 4, 3, "1234" ), 0 );
BOOST_TEST_EQ( sv1.compare( 9, 0, "" ), 0 );
BOOST_TEST_LT( sv1.compare( 9, 1, "1" ), 0 );
BOOST_TEST_THROWS( sv1.compare( 10, 0, "" ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 10, 1, "1" ), std::out_of_range );
BOOST_TEST_GT( sv1.compare( 4, npos, "123456", 4 ), 0 );
BOOST_TEST_EQ( sv1.compare( 4, npos, "123456", 5 ), 0 );
BOOST_TEST_LT( sv1.compare( 4, npos, "123456", 6 ), 0 );
BOOST_TEST_EQ( sv1.compare( 9, npos, "", 0 ), 0 );
BOOST_TEST_EQ( sv1.compare( 9, npos, "1", 0 ), 0 );
BOOST_TEST_LT( sv1.compare( 9, npos, "1", 1 ), 0 );
BOOST_TEST_THROWS( sv1.compare( 10, npos, "", 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 10, npos, "1", 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv1.compare( 10, npos, "1", 1 ), std::out_of_range );
}
return boost::report_errors();
}

346
test/sv_construct_test.cpp Normal file
View File

@@ -0,0 +1,346 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iterator>
#include <string>
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
# include <string_view>
#endif
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
# include <memory_resource>
#endif
template<class It> std::reverse_iterator<It> make_reverse_iterator( It it )
{
return std::reverse_iterator<It>( it );
}
int main()
{
{
boost::core::string_view sv;
BOOST_TEST_EQ( sv.data(), static_cast<char const*>(0) );
BOOST_TEST_EQ( sv.size(), 0 );
BOOST_TEST_EQ( sv.begin(), sv.data() );
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
BOOST_TEST_EQ( sv.length(), sv.size() );
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
}
{
char const* s = "";
boost::core::string_view sv( s );
BOOST_TEST_EQ( sv.data(), s );
BOOST_TEST_EQ( sv.size(), 0 );
BOOST_TEST_EQ( sv.begin(), sv.data() );
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
BOOST_TEST_EQ( sv.length(), sv.size() );
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
if( !sv.empty() )
{
BOOST_TEST_EQ( &sv.front(), sv.data() );
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
}
}
{
char const* s = "123";
boost::core::string_view sv( s );
BOOST_TEST_EQ( sv.data(), s );
BOOST_TEST_EQ( sv.size(), 3 );
BOOST_TEST_EQ( sv.begin(), sv.data() );
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
BOOST_TEST_EQ( sv.length(), sv.size() );
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
if( !sv.empty() )
{
BOOST_TEST_EQ( &sv.front(), sv.data() );
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
}
}
{
char const* s = "123";
boost::core::string_view sv( s, 0 );
BOOST_TEST_EQ( sv.data(), s );
BOOST_TEST_EQ( sv.size(), 0 );
BOOST_TEST_EQ( sv.begin(), sv.data() );
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
BOOST_TEST_EQ( sv.length(), sv.size() );
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
if( !sv.empty() )
{
BOOST_TEST_EQ( &sv.front(), sv.data() );
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
}
}
{
char const* s = "123";
boost::core::string_view sv( s, 2 );
BOOST_TEST_EQ( sv.data(), s );
BOOST_TEST_EQ( sv.size(), 2 );
BOOST_TEST_EQ( sv.begin(), sv.data() );
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
BOOST_TEST_EQ( sv.length(), sv.size() );
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
if( !sv.empty() )
{
BOOST_TEST_EQ( &sv.front(), sv.data() );
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
}
}
{
char const* s = "123";
boost::core::string_view sv( s, s );
BOOST_TEST_EQ( sv.data(), s );
BOOST_TEST_EQ( sv.size(), 0 );
BOOST_TEST_EQ( sv.begin(), sv.data() );
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
BOOST_TEST_EQ( sv.length(), sv.size() );
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
if( !sv.empty() )
{
BOOST_TEST_EQ( &sv.front(), sv.data() );
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
}
}
{
char const* s = "123";
boost::core::string_view sv( s, s + 2 );
BOOST_TEST_EQ( sv.data(), s );
BOOST_TEST_EQ( sv.size(), 2 );
BOOST_TEST_EQ( sv.begin(), sv.data() );
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
BOOST_TEST_EQ( sv.length(), sv.size() );
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
if( !sv.empty() )
{
BOOST_TEST_EQ( &sv.front(), sv.data() );
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
}
}
{
std::string str = "123";
boost::core::string_view sv( str );
BOOST_TEST_EQ( sv.data(), str.data() );
BOOST_TEST_EQ( sv.size(), str.size() );
BOOST_TEST_EQ( sv.begin(), sv.data() );
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
BOOST_TEST_EQ( sv.length(), sv.size() );
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
if( !sv.empty() )
{
BOOST_TEST_EQ( &sv.front(), sv.data() );
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
}
}
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
{
std::string_view str = "123";
boost::core::string_view sv( str );
BOOST_TEST_EQ( sv.data(), str.data() );
BOOST_TEST_EQ( sv.size(), str.size() );
BOOST_TEST_EQ( sv.begin(), sv.data() );
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
BOOST_TEST_EQ( sv.length(), sv.size() );
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
if( !sv.empty() )
{
BOOST_TEST_EQ( &sv.front(), sv.data() );
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
}
}
#endif
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
{
using pmr_string = std::basic_string<char, std::char_traits<char>, std::pmr::polymorphic_allocator<char>>;
pmr_string str = "123";
boost::core::string_view sv( str );
BOOST_TEST_EQ( sv.data(), str.data() );
BOOST_TEST_EQ( sv.size(), str.size() );
BOOST_TEST_EQ( sv.begin(), sv.data() );
BOOST_TEST_EQ( sv.end(), sv.data() + sv.size() );
BOOST_TEST_EQ( sv.cbegin(), sv.data() );
BOOST_TEST_EQ( sv.cend(), sv.data() + sv.size() );
BOOST_TEST( sv.rbegin() == ::make_reverse_iterator( sv.end() ) );
BOOST_TEST( sv.rend() == ::make_reverse_iterator( sv.begin() ) );
BOOST_TEST( sv.crbegin() == ::make_reverse_iterator( sv.cend() ) );
BOOST_TEST( sv.crend() == ::make_reverse_iterator( sv.cbegin() ) );
BOOST_TEST_EQ( sv.length(), sv.size() );
BOOST_TEST_EQ( sv.empty(), sv.size() == 0 );
BOOST_TEST_EQ( sv.max_size(), boost::core::string_view::npos );
if( !sv.empty() )
{
BOOST_TEST_EQ( &sv.front(), sv.data() );
BOOST_TEST_EQ( &sv.back(), sv.data() + sv.size() - 1 );
}
}
#endif
return boost::report_errors();
}

71
test/sv_contains_test.cpp Normal file
View File

@@ -0,0 +1,71 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
int main()
{
{
boost::core::string_view sv( "" );
BOOST_TEST( sv.contains( boost::core::string_view() ) );
BOOST_TEST( sv.contains( boost::core::string_view( "" ) ) );
BOOST_TEST( !sv.contains( boost::core::string_view( "1" ) ) );
BOOST_TEST( !sv.contains( '1' ) );
BOOST_TEST( sv.contains( "" ) );
BOOST_TEST( !sv.contains( "1" ) );
}
{
boost::core::string_view sv( "123123" );
BOOST_TEST( sv.contains( boost::core::string_view() ) );
BOOST_TEST( sv.contains( boost::core::string_view( "" ) ) );
BOOST_TEST( sv.contains( boost::core::string_view( "1" ) ) );
BOOST_TEST( sv.contains( boost::core::string_view( "2" ) ) );
BOOST_TEST( sv.contains( boost::core::string_view( "3" ) ) );
BOOST_TEST( !sv.contains( boost::core::string_view( "4" ) ) );
BOOST_TEST( sv.contains( boost::core::string_view( "12" ) ) );
BOOST_TEST( sv.contains( boost::core::string_view( "23" ) ) );
BOOST_TEST( !sv.contains( boost::core::string_view( "34" ) ) );
BOOST_TEST( !sv.contains( boost::core::string_view( "21" ) ) );
BOOST_TEST( sv.contains( '1' ) );
BOOST_TEST( sv.contains( '2' ) );
BOOST_TEST( sv.contains( '3' ) );
BOOST_TEST( !sv.contains( '4' ) );
BOOST_TEST( sv.contains( "" ) );
BOOST_TEST( sv.contains( "1" ) );
BOOST_TEST( sv.contains( "2" ) );
BOOST_TEST( sv.contains( "3" ) );
BOOST_TEST( !sv.contains( "4" ) );
BOOST_TEST( sv.contains( "12" ) );
BOOST_TEST( sv.contains( "23" ) );
BOOST_TEST( !sv.contains( "34" ) );
BOOST_TEST( !sv.contains( "21" ) );
BOOST_TEST( sv.contains( "123" ) );
BOOST_TEST( !sv.contains( "234" ) );
BOOST_TEST( sv.contains( "231" ) );
BOOST_TEST( !sv.contains( "321" ) );
BOOST_TEST( !sv.contains( "1234" ) );
BOOST_TEST( sv.contains( "1231" ) );
BOOST_TEST( sv.contains( "123123" ) );
BOOST_TEST( !sv.contains( "1231231" ) );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,54 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <string>
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
# include <string_view>
#endif
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
# include <memory_resource>
#endif
boost::core::string_view f( boost::core::string_view const& str )
{
return str;
}
int main()
{
{
std::string s1( "123" );
std::string s2 = f( s1 );
BOOST_TEST_EQ( s1, s2 );
}
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
{
std::string_view s1( "123" );
std::string_view s2 = f( s1 );
BOOST_TEST_EQ( s1, s2 );
}
#endif
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
{
using pmr_string = std::basic_string<char, std::char_traits<char>, std::pmr::polymorphic_allocator<char>>;
pmr_string s1( "123" );
pmr_string s2 = f( s1 );
BOOST_TEST_EQ( s1, s2 );
}
#endif
return boost::report_errors();
}

52
test/sv_copy_test.cpp Normal file
View File

@@ -0,0 +1,52 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#define _SCL_SECURE_NO_WARNINGS
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept>
#include <cstddef>
int main()
{
{
boost::core::string_view sv;
BOOST_TEST_EQ( sv.copy( 0, 0 ), 0 );
BOOST_TEST_EQ( sv.copy( 0, 0, 0 ), 0 );
BOOST_TEST_THROWS( sv.copy( 0, 0, 1 ), std::out_of_range );
BOOST_TEST_THROWS( sv.copy( 0, 0, boost::core::string_view::npos ), std::out_of_range );
}
{
boost::core::string_view sv( "12345" );
char buffer[ 8 ] = {};
BOOST_TEST_EQ( sv.copy( buffer, 0 ), 0 );
BOOST_TEST_EQ( buffer[0], 0 );
BOOST_TEST_EQ( sv.copy( buffer, 0, 0 ), 0 );
BOOST_TEST_EQ( buffer[0], 0 );
BOOST_TEST_EQ( sv.copy( buffer, 0, 1 ), 0 );
BOOST_TEST_EQ( buffer[0], 0 );
BOOST_TEST_THROWS( sv.copy( buffer, 0, boost::core::string_view::npos ), std::out_of_range );
BOOST_TEST_EQ( buffer[0], 0 );
BOOST_TEST_EQ( sv.copy( buffer, 1 ), 1 );
BOOST_TEST_EQ( buffer[0], '1' );
BOOST_TEST_EQ( buffer[1], 0 );
BOOST_TEST_EQ( sv.copy( buffer, 1, 1 ), 1 );
BOOST_TEST_EQ( buffer[0], '2' );
BOOST_TEST_EQ( buffer[1], 0 );
BOOST_TEST_EQ( sv.copy( buffer, 8 ), 5 );
BOOST_TEST_CSTR_EQ( buffer, "12345" );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,41 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept>
int main()
{
{
boost::core::string_view sv( "12345" );
for( std::size_t i = 0; i < 5; ++i )
{
BOOST_TEST_EQ( &sv[ i ], sv.data() + i );
BOOST_TEST_EQ( &sv.at( i ), sv.data() + i );
}
BOOST_TEST_THROWS( sv.at( 5 ), std::out_of_range );
BOOST_TEST_THROWS( sv.at( boost::core::string_view::npos ), std::out_of_range );
}
{
boost::core::string_view sv;
BOOST_TEST_THROWS( sv.at( 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv.at( 1 ), std::out_of_range );
BOOST_TEST_THROWS( sv.at( boost::core::string_view::npos ), std::out_of_range );
}
{
boost::core::string_view sv( "12345", 0 );
BOOST_TEST_THROWS( sv.at( 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv.at( 1 ), std::out_of_range );
BOOST_TEST_THROWS( sv.at( boost::core::string_view::npos ), std::out_of_range );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,50 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept>
#include <cstddef>
int main()
{
{
boost::core::string_view sv( "" );
BOOST_TEST( sv.ends_with( boost::core::string_view() ) );
BOOST_TEST( sv.ends_with( boost::core::string_view( "" ) ) );
BOOST_TEST( sv.ends_with( "" ) );
BOOST_TEST( !sv.ends_with( boost::core::string_view( "1" ) ) );
BOOST_TEST( !sv.ends_with( '1' ) );
BOOST_TEST( !sv.ends_with( "1" ) );
}
{
boost::core::string_view sv( "123" );
BOOST_TEST( sv.ends_with( boost::core::string_view() ) );
BOOST_TEST( sv.ends_with( boost::core::string_view( "" ) ) );
BOOST_TEST( sv.ends_with( "" ) );
BOOST_TEST( sv.ends_with( boost::core::string_view( "3" ) ) );
BOOST_TEST( sv.ends_with( '3' ) );
BOOST_TEST( sv.ends_with( "3" ) );
BOOST_TEST( sv.ends_with( boost::core::string_view( "23" ) ) );
BOOST_TEST( sv.ends_with( "23" ) );
BOOST_TEST( sv.ends_with( boost::core::string_view( "123" ) ) );
BOOST_TEST( sv.ends_with( "123" ) );
BOOST_TEST( !sv.ends_with( boost::core::string_view( "1234" ) ) );
BOOST_TEST( !sv.ends_with( "1234" ) );
BOOST_TEST( !sv.ends_with( boost::core::string_view( "2" ) ) );
BOOST_TEST( !sv.ends_with( '2' ) );
BOOST_TEST( !sv.ends_with( "2" ) );
}
return boost::report_errors();
}

113
test/sv_eq_test.cpp Normal file
View File

@@ -0,0 +1,113 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
# include <string_view>
#endif
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
# include <memory_resource>
#endif
#define TEST_EQ(x, y) \
BOOST_TEST_EQ(x, y); \
BOOST_TEST_NOT((x) != (y)); \
BOOST_TEST_LE(x, y); \
BOOST_TEST_GE(x, y); \
BOOST_TEST_NOT((x) < (y)); \
BOOST_TEST_NOT((x) > (y))
#define TEST_NE(x, y) \
BOOST_TEST_NE(x, y); \
BOOST_TEST_NOT((x) == (y)); \
BOOST_TEST((x) < (y) || (x) > (y));
int main()
{
{
boost::core::string_view sv1( "" );
boost::core::string_view sv2( "" );
boost::core::string_view sv3( "123" );
boost::core::string_view sv4( "123" );
boost::core::string_view sv5( "12345" );
boost::core::string_view sv6( "12345" );
TEST_EQ( sv1, sv1 );
TEST_EQ( sv1, sv2 );
TEST_NE( sv1, sv3 );
TEST_NE( sv1, sv5 );
TEST_EQ( sv3, sv3 );
TEST_EQ( sv3, sv4 );
TEST_NE( sv3, sv1 );
TEST_NE( sv3, sv5 );
TEST_EQ( sv5, sv5 );
TEST_EQ( sv5, sv6 );
TEST_NE( sv5, sv1 );
TEST_NE( sv5, sv3 );
BOOST_TEST_EQ( sv1, std::string( "" ) );
BOOST_TEST_EQ( std::string( "" ), sv1 );
BOOST_TEST_NE( sv1, std::string( "1" ) );
BOOST_TEST_NE( std::string( "1" ), sv1 );
BOOST_TEST_EQ( sv3, std::string( "123" ) );
BOOST_TEST_EQ( std::string( "123" ), sv3 );
BOOST_TEST_NE( sv3, std::string( "122" ) );
BOOST_TEST_NE( std::string( "122" ), sv3 );
BOOST_TEST_EQ( sv1, "" );
BOOST_TEST_EQ( "", sv1 );
BOOST_TEST_NE( sv1, "1" );
BOOST_TEST_NE( "1", sv1 );
BOOST_TEST_EQ( sv3, "123" );
BOOST_TEST_EQ( "123", sv3 );
BOOST_TEST_NE( sv3, "122" );
BOOST_TEST_NE( "122", sv3 );
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
BOOST_TEST_EQ( sv1, std::string_view( "" ) );
BOOST_TEST_EQ( std::string_view( "" ), sv1 );
BOOST_TEST_NE( sv1, std::string_view( "1" ) );
BOOST_TEST_NE( std::string_view( "1" ), sv1 );
BOOST_TEST_EQ( sv3, std::string_view( "123" ) );
BOOST_TEST_EQ( std::string_view( "123" ), sv3 );
BOOST_TEST_NE( sv3, std::string_view( "122" ) );
BOOST_TEST_NE( std::string_view( "122" ), sv3 );
#endif
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
using pmr_string = std::basic_string<char, std::char_traits<char>, std::pmr::polymorphic_allocator<char>>;
BOOST_TEST_EQ( sv1, pmr_string( "" ) );
BOOST_TEST_EQ( pmr_string( "" ), sv1 );
BOOST_TEST_NE( sv1, pmr_string( "1" ) );
BOOST_TEST_NE( pmr_string( "1" ), sv1 );
BOOST_TEST_EQ( sv3, pmr_string( "123" ) );
BOOST_TEST_EQ( pmr_string( "123" ), sv3 );
BOOST_TEST_NE( sv3, pmr_string( "122" ) );
BOOST_TEST_NE( pmr_string( "122" ), sv3 );
#endif
}
return boost::report_errors();
}

View File

@@ -0,0 +1,648 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <algorithm>
#include <cstddef>
int main()
{
std::size_t const npos = boost::core::string_view::npos;
{
boost::core::string_view sv( "" );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view() ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ) ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ) ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( '1' ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( '1', 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "" ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "1" ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "1", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "12", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "12", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "12", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "12", 1, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "12", 0, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "12", 1, 2 ), npos );
}
{
boost::core::wstring_view sv( L"" );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view() ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ) ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ) ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L'1' ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"" ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"1" ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 1, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 0, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"12", 1, 2 ), npos );
}
{
boost::core::string_view sv( "123123" );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view() ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view(), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ) ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ) ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 0 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "1" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ) ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "4" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ) ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 4 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 5 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::string_view( "23" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( '1' ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( '1', 0 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( '1', 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( '1', 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( '1', 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( '1', 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( '1', 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( '1', 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( '1', 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( '3' ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( '3', 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( '3', 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( '3', 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( '3', 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( '3', 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( '3', 5 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( '3', 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( '3', 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( '9' ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( '9', 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( '9', 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( '9', 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( '9', 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( '9', 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( '9', 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( '9', 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( '9', 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "" ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( "", 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( "", 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( "", 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( "", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "", 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( "", 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( "", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "1" ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( "1", 0 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( "1", 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( "1", 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( "1", 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( "1", 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( "1", 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( "1", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "1", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "23" ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( "23", 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( "23", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "23", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "23", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "23", 4 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "23", 5 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "23", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "23", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 0, 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 1, 0 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 2, 0 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 3, 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 4, 0 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 5, 0 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 6, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 7, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 0, 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 1, 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 2, 1 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 3, 1 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 4, 1 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 5, 1 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 6, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 7, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 0, 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 1, 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 2, 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 3, 2 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 4, 2 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 5, 2 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 6, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 7, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 0, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 1, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 2, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 3, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 4, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 5, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 6, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( "123", 7, 3 ), npos );
}
{
boost::core::wstring_view sv( L"123123" );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view() ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view(), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ) ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ) ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 0 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"1" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ) ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"4" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ) ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 4 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 5 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( boost::core::wstring_view( L"23" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L'1' ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 0 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L'1', 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L'3' ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 5 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L'3', 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L'9' ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L'9', 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"" ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( L"", 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( L"", 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L"", 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"", 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L"", 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"1" ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 0 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"1", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"23" ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 4 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 5 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"23", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 0, 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 1, 0 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 2, 0 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 3, 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 4, 0 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 5, 0 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 6, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 7, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 0, 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 1, 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 2, 1 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 3, 1 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 4, 1 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 5, 1 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 6, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 7, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 0, 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 1, 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 2, 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 3, 2 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 4, 2 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 5, 2 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 6, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 7, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 0, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 1, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 2, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 3, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 4, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 5, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 6, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"123", 7, 3 ), npos );
}
{
boost::core::wstring_view sv( L"\x101\x102\x103\x101\x102\x103" );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 0, 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 1, 0 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 2, 0 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 3, 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 4, 0 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 5, 0 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 6, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 7, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 0, 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 1, 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 2, 1 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 3, 1 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 4, 1 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 5, 1 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 6, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 7, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 0, 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 1, 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 2, 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 3, 2 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 4, 2 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 5, 2 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 6, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 7, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 0, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 1, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 2, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 3, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 4, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 5, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 6, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( L"\x101\x102\x103", 7, 3 ), npos );
}
{
boost::core::string_view sv( "123a123B123c" );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789" ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( "0123456789", 12 ), npos );
}
{
boost::core::wstring_view sv( L"123a123B123c" );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789" ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( L"0123456789", 12 ), npos );
}
{
boost::core::string_view sv( "abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), npos );
}
{
boost::core::wstring_view sv( L"abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), npos );
}
{
char str[ 256 ];
for( int i = 0; i < 256; ++i )
{
str[ i ] = static_cast< unsigned char >( i );
}
boost::core::string_view sv( str, 256 );
BOOST_TEST_EQ( sv.find_first_not_of( sv ), npos );
std::string str2( sv.data(), sv.size() );
for( int i = 0; i < 256; ++i )
{
std::string str3( str2 );
str3[ i ] = ~str3[ i ];
BOOST_TEST_EQ( sv.find_first_not_of( str3 ), i );
}
std::reverse( str, str + 256 );
for( int i = 0; i < 256; ++i )
{
std::string str3( str2 );
str3[ i ] = ~str3[ i ];
BOOST_TEST_EQ( sv.find_first_not_of( str3 ), 255 - i );
}
}
{
wchar_t str[ 256 ];
for( int i = 0; i < 256; ++i )
{
str[ i ] = static_cast< wchar_t >( 0x100 + i );
}
boost::core::wstring_view sv( str, 256 );
BOOST_TEST_EQ( sv.find_first_not_of( sv ), npos );
std::wstring str2( sv.data(), sv.size() );
for( int i = 0; i < 256; ++i )
{
std::wstring str3( str2 );
str3[ i ] = ~str3[ i ];
BOOST_TEST_EQ( sv.find_first_not_of( str3 ), i );
}
std::reverse( str, str + 256 );
for( int i = 0; i < 256; ++i )
{
std::wstring str3( str2 );
str3[ i ] = ~str3[ i ];
BOOST_TEST_EQ( sv.find_first_not_of( str3 ), 255 - i );
}
}
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
{
boost::core::u8string_view sv( u8"123123" );
BOOST_TEST_EQ( sv.find_first_not_of( u8"" ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"1" ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 0 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"1", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"23" ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 4 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 5 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"23", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 0 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 2 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 3 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 4 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 5 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_not_of( u8"123", 7 ), npos );
}
{
boost::core::u8string_view sv( u8"123a123B123c" );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789" ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"0123456789", 12 ), npos );
}
{
boost::core::u8string_view sv( u8"abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), npos );
}
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,553 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <algorithm>
#include <cstddef>
int main()
{
std::size_t const npos = boost::core::string_view::npos;
{
boost::core::string_view sv( "" );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view() ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "" ) ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "1" ) ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "1" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( '1' ), npos );
BOOST_TEST_EQ( sv.find_first_of( '1', 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "" ), npos );
BOOST_TEST_EQ( sv.find_first_of( "", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "1" ), npos );
BOOST_TEST_EQ( sv.find_first_of( "1", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "12", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "12", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "12", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "12", 1, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "12", 0, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "12", 1, 2 ), npos );
}
{
boost::core::wstring_view sv( L"" );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view() ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"" ) ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"1" ) ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"1" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L'1' ), npos );
BOOST_TEST_EQ( sv.find_first_of( L'1', 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"" ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"1" ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"1", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"12", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"12", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"12", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"12", 1, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"12", 0, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"12", 1, 2 ), npos );
}
{
boost::core::string_view sv( "123123" );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view() ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view(), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view(), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "" ) ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "1" ) ), 0 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "1" ), 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "1" ), 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "1" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "1" ), 4 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "1" ), 5 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "1" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "1" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "4" ) ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "4" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "4" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "4" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "23" ) ), 1 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "23" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "23" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "23" ), 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "23" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "23" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "23" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::string_view( "23" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( '1' ), 0 );
BOOST_TEST_EQ( sv.find_first_of( '1', 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( '1', 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( '1', 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( '1', 4 ), npos );
BOOST_TEST_EQ( sv.find_first_of( '1', 5 ), npos );
BOOST_TEST_EQ( sv.find_first_of( '1', 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( '1', 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( '3' ), 2 );
BOOST_TEST_EQ( sv.find_first_of( '3', 1 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( '3', 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( '3', 3 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( '3', 4 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( '3', 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( '3', 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( '3', 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( '9' ), npos );
BOOST_TEST_EQ( sv.find_first_of( "" ), npos );
BOOST_TEST_EQ( sv.find_first_of( "", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "1" ), 0 );
BOOST_TEST_EQ( sv.find_first_of( "1", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "1", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "1", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "1", 4 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "1", 5 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "1", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "1", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "23" ), 1 );
BOOST_TEST_EQ( sv.find_first_of( "23", 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( "23", 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( "23", 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( "23", 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( "23", 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( "23", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "23", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 2, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 3, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 4, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 5, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 6, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 7, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 0, 1 ), 0 );
BOOST_TEST_EQ( sv.find_first_of( "123", 1, 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "123", 2, 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "123", 3, 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "123", 4, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 5, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 6, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 7, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 0, 2 ), 0 );
BOOST_TEST_EQ( sv.find_first_of( "123", 1, 2 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( "123", 2, 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "123", 3, 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "123", 4, 2 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( "123", 5, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 6, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 7, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 0, 3 ), 0 );
BOOST_TEST_EQ( sv.find_first_of( "123", 1, 3 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( "123", 2, 3 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( "123", 3, 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "123", 4, 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( "123", 5, 3 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( "123", 6, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_of( "123", 7, 3 ), npos );
}
{
boost::core::wstring_view sv( L"123123" );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view() ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view(), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view(), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"" ) ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"1" ) ), 0 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"1" ), 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"1" ), 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"1" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"1" ), 4 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"1" ), 5 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"1" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"1" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"4" ) ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"4" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"4" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"4" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"23" ) ), 1 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"23" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"23" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"23" ), 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"23" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"23" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"23" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( boost::core::wstring_view( L"23" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L'1' ), 0 );
BOOST_TEST_EQ( sv.find_first_of( L'1', 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L'1', 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L'1', 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L'1', 4 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L'1', 5 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L'1', 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L'1', 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L'3' ), 2 );
BOOST_TEST_EQ( sv.find_first_of( L'3', 1 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( L'3', 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( L'3', 3 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( L'3', 4 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( L'3', 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( L'3', 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L'3', 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L'9' ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"" ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"1" ), 0 );
BOOST_TEST_EQ( sv.find_first_of( L"1", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"1", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"1", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"1", 4 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"1", 5 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"1", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"1", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"23" ), 1 );
BOOST_TEST_EQ( sv.find_first_of( L"23", 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( L"23", 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( L"23", 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( L"23", 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( L"23", 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( L"23", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"23", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 2, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 3, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 4, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 5, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 6, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 7, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 0, 1 ), 0 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 1, 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 2, 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 3, 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 4, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 5, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 6, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 7, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 0, 2 ), 0 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 1, 2 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 2, 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 3, 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 4, 2 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 5, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 6, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 7, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 0, 3 ), 0 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 1, 3 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 2, 3 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 3, 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 4, 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 5, 3 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( L"123", 6, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"123", 7, 3 ), npos );
}
{
boost::core::wstring_view sv( L"\x101\x102\x103\x101\x102\x103" );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 2, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 3, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 4, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 5, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 6, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 7, 0 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 0, 1 ), 0 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 1, 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 2, 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 3, 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 4, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 5, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 6, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 7, 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 0, 2 ), 0 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 1, 2 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 2, 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 3, 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 4, 2 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 5, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 6, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 7, 2 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 0, 3 ), 0 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 1, 3 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 2, 3 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 3, 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 4, 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 5, 3 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 6, 3 ), npos );
BOOST_TEST_EQ( sv.find_first_of( L"\x101\x102\x103", 7, 3 ), npos );
}
{
boost::core::string_view sv( "abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_first_of( "0123456789" ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( "0123456789", 12 ), npos );
}
{
boost::core::wstring_view sv( L"abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789" ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( L"0123456789", 12 ), npos );
}
{
boost::core::string_view sv( "123a123B123c" );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), npos );
}
{
boost::core::wstring_view sv( L"123a123B123c" );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), npos );
}
{
char str[ 256 ];
for( int i = 0; i < 256; ++i )
{
str[ i ] = static_cast< unsigned char >( i );
}
boost::core::string_view sv( str, 256 );
for( int i = 0; i < 256; ++i )
{
std::string needle( 12, static_cast< unsigned char >( i ) );
BOOST_TEST_EQ( sv.find_first_of( needle ), i );
}
std::reverse( str, str + 256 );
for( int i = 0; i < 256; ++i )
{
std::string needle( 12, static_cast< unsigned char >( i ) );
BOOST_TEST_EQ( sv.find_first_of( needle ), 255 - i );
}
}
{
wchar_t str[ 256 ];
for( int i = 0; i < 256; ++i )
{
str[ i ] = static_cast< wchar_t >( 0x100 + i );
}
boost::core::wstring_view sv( str, 256 );
for( int i = 0; i < 256; ++i )
{
std::wstring needle( 12, static_cast< wchar_t >( 0x100 + i ) );
BOOST_TEST_EQ( sv.find_first_of( needle ), i );
}
std::reverse( str, str + 256 );
for( int i = 0; i < 256; ++i )
{
std::wstring needle( 12, static_cast< wchar_t >( 0x100 + i ) );
BOOST_TEST_EQ( sv.find_first_of( needle ), 255 - i );
}
}
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
{
boost::core::u8string_view sv( u8"123123" );
BOOST_TEST_EQ( sv.find_first_of( u8"" ), npos );
BOOST_TEST_EQ( sv.find_first_of( u8"", 1 ), npos );
BOOST_TEST_EQ( sv.find_first_of( u8"", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( u8"", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( u8"1" ), 0 );
BOOST_TEST_EQ( sv.find_first_of( u8"1", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"1", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"1", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"1", 4 ), npos );
BOOST_TEST_EQ( sv.find_first_of( u8"1", 5 ), npos );
BOOST_TEST_EQ( sv.find_first_of( u8"1", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( u8"1", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( u8"23" ), 1 );
BOOST_TEST_EQ( sv.find_first_of( u8"23", 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( u8"23", 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( u8"23", 3 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( u8"23", 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( u8"23", 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( u8"23", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( u8"23", 7 ), npos );
BOOST_TEST_EQ( sv.find_first_of( u8"123", 0 ), 0 );
BOOST_TEST_EQ( sv.find_first_of( u8"123", 1 ), 1 );
BOOST_TEST_EQ( sv.find_first_of( u8"123", 2 ), 2 );
BOOST_TEST_EQ( sv.find_first_of( u8"123", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"123", 4 ), 4 );
BOOST_TEST_EQ( sv.find_first_of( u8"123", 5 ), 5 );
BOOST_TEST_EQ( sv.find_first_of( u8"123", 6 ), npos );
BOOST_TEST_EQ( sv.find_first_of( u8"123", 7 ), npos );
}
{
boost::core::u8string_view sv( u8"abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789" ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( u8"0123456789", 12 ), npos );
}
{
boost::core::u8string_view sv( u8"123a123B123c" );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_first_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), npos );
}
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,648 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <algorithm>
#include <cstddef>
int main()
{
std::size_t const npos = boost::core::string_view::npos;
{
boost::core::string_view sv( "" );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view() ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "" ) ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "1" ) ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "1" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( '1' ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( '1', 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "" ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "1" ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "1", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "12", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "12", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "12", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "12", 1, 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "12", 0, 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "12", 1, 2 ), npos );
}
{
boost::core::wstring_view sv( L"" );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view() ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"" ) ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"1" ) ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"1" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L'1' ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L'1', 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"" ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"1" ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"1", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"12", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"12", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"12", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"12", 1, 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"12", 0, 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"12", 1, 2 ), npos );
}
{
boost::core::string_view sv( "123123" );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view(), 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view(), 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view(), 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view(), 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view(), 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view(), 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view(), 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view(), 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view() ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "" ), 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "" ), 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "" ) ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "1" ), 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "1" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "1" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "1" ), 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "1" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "1" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "1" ), 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "1" ), 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "1" ) ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "4" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "4" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "4" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "4" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "4" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "4" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "4" ), 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "4" ), 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "4" ) ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "23" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "23" ), 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "23" ), 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "23" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "23" ), 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "23" ), 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "23" ), 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "23" ), 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::string_view( "23" ) ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( '1', 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( '1', 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( '1', 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( '1', 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( '1', 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( '1', 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( '1', 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( '1', 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( '1' ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( '3', 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( '3', 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( '3', 2 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( '3', 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( '3', 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( '3', 5 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( '3', 6 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( '3', 7 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( '3' ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( '9', 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( '9', 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( '9', 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( '9', 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( '9', 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( '9', 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( '9', 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( '9', 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( '9' ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "", 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( "", 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( "", 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( "", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "", 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( "", 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "", 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "", 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "" ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "1", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "1", 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( "1", 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( "1", 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( "1", 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( "1", 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "1", 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "1", 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "1" ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "23", 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( "23", 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( "23", 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( "23", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "23", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "23", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "23", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "23", 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "23" ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 0, 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 1, 0 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 2, 0 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 3, 0 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 4, 0 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 5, 0 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 6, 0 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 7, 0 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 1, 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 2, 1 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 3, 1 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 4, 1 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 5, 1 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 6, 1 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 7, 1 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 0, 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 1, 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 2, 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 3, 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 4, 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 5, 2 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 6, 2 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 7, 2 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 0, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 1, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 2, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 3, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 4, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 5, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 6, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "123", 7, 3 ), npos );
}
{
boost::core::wstring_view sv( L"123123" );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view(), 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view(), 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view(), 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view(), 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view(), 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view(), 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view(), 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view(), 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view() ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"" ), 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"" ), 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"" ) ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"1" ), 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"1" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"1" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"1" ), 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"1" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"1" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"1" ), 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"1" ), 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"1" ) ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"4" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"4" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"4" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"4" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"4" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"4" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"4" ), 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"4" ), 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"4" ) ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"23" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"23" ), 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"23" ), 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"23" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"23" ), 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"23" ), 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"23" ), 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"23" ), 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( boost::core::wstring_view( L"23" ) ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L'1', 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L'1', 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( L'1', 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L'1', 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L'1', 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L'1', 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L'1', 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L'1', 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L'1' ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L'3', 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( L'3', 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( L'3', 2 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( L'3', 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L'3', 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L'3', 5 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L'3', 6 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L'3', 7 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L'3' ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L'9', 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( L'9', 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( L'9', 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L'9', 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L'9', 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L'9', 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L'9', 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L'9', 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L'9' ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"", 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( L"", 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( L"", 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"", 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L"", 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"", 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"", 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"" ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"1", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"1", 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( L"1", 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"1", 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"1", 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L"1", 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"1", 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"1", 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"1" ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"23", 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( L"23", 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( L"23", 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( L"23", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"23", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"23", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"23", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"23", 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"23" ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 0, 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 1, 0 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 2, 0 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 3, 0 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 4, 0 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 5, 0 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 6, 0 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 7, 0 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 1, 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 2, 1 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 3, 1 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 4, 1 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 5, 1 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 6, 1 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 7, 1 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 0, 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 1, 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 2, 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 3, 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 4, 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 5, 2 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 6, 2 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 7, 2 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 0, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 1, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 2, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 3, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 4, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 5, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 6, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"123", 7, 3 ), npos );
}
{
boost::core::wstring_view sv( L"\x101\x102\x103\x101\x102\x103" );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 0, 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 1, 0 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 2, 0 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 3, 0 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 4, 0 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 5, 0 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 6, 0 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 7, 0 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 1, 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 2, 1 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 3, 1 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 4, 1 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 5, 1 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 6, 1 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 7, 1 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 0, 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 1, 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 2, 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 3, 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 4, 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 5, 2 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 6, 2 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 7, 2 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 0, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 1, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 2, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 3, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 4, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 5, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 6, 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"\x101\x102\x103", 7, 3 ), npos );
}
{
boost::core::string_view sv( "123a123B123c" );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( "0123456789" ), 11 );
}
{
boost::core::wstring_view sv( L"123a123B123c" );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( L"0123456789" ), 11 );
}
{
boost::core::string_view sv( "abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 11 );
}
{
boost::core::wstring_view sv( L"abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 11 );
}
{
char str[ 256 ];
for( int i = 0; i < 256; ++i )
{
str[ i ] = static_cast< unsigned char >( i );
}
boost::core::string_view sv( str, 256 );
BOOST_TEST_EQ( sv.find_last_not_of( sv ), npos );
std::string str2( sv.data(), sv.size() );
for( int i = 0; i < 256; ++i )
{
std::string str3( str2 );
str3[ i ] = ~str3[ i ];
BOOST_TEST_EQ( sv.find_last_not_of( str3 ), i );
}
std::reverse( str, str + 256 );
for( int i = 0; i < 256; ++i )
{
std::string str3( str2 );
str3[ i ] = ~str3[ i ];
BOOST_TEST_EQ( sv.find_last_not_of( str3 ), 255 - i );
}
}
{
wchar_t str[ 256 ];
for( int i = 0; i < 256; ++i )
{
str[ i ] = static_cast< wchar_t >( 0x100 + i );
}
boost::core::wstring_view sv( str, 256 );
BOOST_TEST_EQ( sv.find_first_not_of( sv ), npos );
std::wstring str2( sv.data(), sv.size() );
for( int i = 0; i < 256; ++i )
{
std::wstring str3( str2 );
str3[ i ] = ~str3[ i ];
BOOST_TEST_EQ( sv.find_first_not_of( str3 ), i );
}
std::reverse( str, str + 256 );
for( int i = 0; i < 256; ++i )
{
std::wstring str3( str2 );
str3[ i ] = ~str3[ i ];
BOOST_TEST_EQ( sv.find_first_not_of( str3 ), 255 - i );
}
}
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
{
boost::core::u8string_view sv( u8"123123" );
BOOST_TEST_EQ( sv.find_last_not_of( u8"", 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"", 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"", 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"", 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"", 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"", 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"", 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"" ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"1", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"1", 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"1", 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"1", 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"1", 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"1", 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"1", 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"1", 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"1" ), 5 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"23", 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"23", 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"23", 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"23", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"23", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"23", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"23", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"23", 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"23" ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"123", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"123", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"123", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"123", 3 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"123", 4 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"123", 5 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"123", 6 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"123", 7 ), npos );
}
{
boost::core::u8string_view sv( u8"123a123B123c" );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"0123456789" ), 11 );
}
{
boost::core::u8string_view sv( u8"abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_not_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 11 );
}
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,575 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <algorithm>
#include <cstddef>
int main()
{
std::size_t const npos = boost::core::string_view::npos;
{
boost::core::string_view sv( "" );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view() ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ) ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ) ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( '1' ), npos );
BOOST_TEST_EQ( sv.find_last_of( '1', 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "" ), npos );
BOOST_TEST_EQ( sv.find_last_of( "", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "1" ), npos );
BOOST_TEST_EQ( sv.find_last_of( "1", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "12", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "12", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "12", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "12", 1, 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "12", 0, 2 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "12", 1, 2 ), npos );
}
{
boost::core::wstring_view sv( L"" );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view() ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ) ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ) ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L'1' ), npos );
BOOST_TEST_EQ( sv.find_last_of( L'1', 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"" ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"1" ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"1", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"12", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"12", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"12", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"12", 1, 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"12", 0, 2 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"12", 1, 2 ), npos );
}
{
boost::core::string_view sv( "123123" );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view(), 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view(), 6 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view(), 7 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view() ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ) ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ), 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "1" ) ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "4" ), 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "4" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "4" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "4" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "4" ) ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ), 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::string_view( "23" ) ), 5 );
BOOST_TEST_EQ( sv.find_last_of( '1', 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( '1', 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( '1', 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( '1', 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( '1', 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( '1', 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( '1', 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( '1', 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( '1' ), 3 );
BOOST_TEST_EQ( sv.find_last_of( '3', 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( '3', 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( '3', 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( '3', 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( '3', 4 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( '3', 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( '3', 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( '3', 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( '3' ), 5 );
BOOST_TEST_EQ( sv.find_last_of( '9' ), npos );
BOOST_TEST_EQ( sv.find_last_of( "", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "", 6 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "", 7 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "" ), npos );
BOOST_TEST_EQ( sv.find_last_of( "1", 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( "1", 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( "1", 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( "1", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "1", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "1", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "1", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "1", 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "1" ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "23", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "23", 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( "23", 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( "23", 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( "23", 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( "23", 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( "23", 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( "23", 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( "23" ), 5 );
BOOST_TEST_EQ( sv.find_last_of( "123", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "123", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "123", 2, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "123", 3, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "123", 4, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "123", 5, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "123", 6, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "123", 7, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "123", 0, 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( "123", 1, 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( "123", 2, 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( "123", 3, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "123", 4, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "123", 5, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "123", 6, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "123", 7, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "123", 0, 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( "123", 1, 2 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( "123", 2, 2 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( "123", 3, 2 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "123", 4, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( "123", 5, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( "123", 6, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( "123", 7, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( "123", 0, 3 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( "123", 1, 3 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( "123", 2, 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( "123", 3, 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "123", 4, 3 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( "123", 5, 3 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( "123", 6, 3 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( "123", 7, 3 ), 5 );
}
{
boost::core::wstring_view sv( L"123123" );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view(), 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view(), 6 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view(), 7 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view() ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ) ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ), 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"1" ) ), 3 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"4" ), 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"4" ), 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"4" ), 6 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"4" ), 7 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"4" ) ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ), 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( boost::core::wstring_view( L"23" ) ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L'1', 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L'1', 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L'1', 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L'1', 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L'1', 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L'1', 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L'1', 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L'1', 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L'1' ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L'3', 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L'3', 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L'3', 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( L'3', 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( L'3', 4 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( L'3', 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L'3', 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L'3', 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L'3' ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L'9' ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"", 6 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"", 7 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"" ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"1", 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"1", 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"1", 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"1", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"1", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"1", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"1", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"1", 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"1" ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"23", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"23", 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( L"23", 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( L"23", 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( L"23", 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( L"23", 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L"23", 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L"23", 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L"23" ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"123", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"123", 2, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"123", 3, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"123", 4, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"123", 5, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"123", 6, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"123", 7, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"123", 0, 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 1, 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 2, 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 3, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 4, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 5, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 6, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 7, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 0, 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 1, 2 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 2, 2 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 3, 2 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 4, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 5, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 6, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 7, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 0, 3 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 1, 3 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 2, 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 3, 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 4, 3 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 5, 3 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 6, 3 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L"123", 7, 3 ), 5 );
}
{
boost::core::wstring_view sv( L"\x101\x102\x103\x101\x102\x103" );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 0, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 2, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 3, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 4, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 5, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 6, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 7, 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 0, 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 1, 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 2, 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 3, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 4, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 5, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 6, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 7, 1 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 0, 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 1, 2 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 2, 2 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 3, 2 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 4, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 5, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 6, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 7, 2 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 0, 3 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 1, 3 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 2, 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 3, 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 4, 3 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 5, 3 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 6, 3 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( L"\x101\x102\x103", 7, 3 ), 5 );
}
{
boost::core::string_view sv( "abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( "0123456789", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( "0123456789" ), 11 );
}
{
boost::core::wstring_view sv( L"abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( L"0123456789" ), 11 );
}
{
boost::core::string_view sv( "123a123B123c" );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 11 );
}
{
boost::core::wstring_view sv( L"123a123B123c" );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 11 );
}
{
char str[ 256 ];
for( int i = 0; i < 256; ++i )
{
str[ i ] = static_cast< unsigned char >( i );
}
boost::core::string_view sv( str, 256 );
for( int i = 0; i < 256; ++i )
{
std::string needle( 12, static_cast< unsigned char >( i ) );
BOOST_TEST_EQ( sv.find_last_of( needle ), i );
}
std::reverse( str, str + 256 );
for( int i = 0; i < 256; ++i )
{
std::string needle( 12, static_cast< unsigned char >( i ) );
BOOST_TEST_EQ( sv.find_last_of( needle ), 255 - i );
}
}
{
wchar_t str[ 256 ];
for( int i = 0; i < 256; ++i )
{
str[ i ] = static_cast< wchar_t >( 0x100 + i );
}
boost::core::wstring_view sv( str, 256 );
for( int i = 0; i < 256; ++i )
{
std::wstring needle( 12, static_cast< wchar_t >( 0x100 + i ) );
BOOST_TEST_EQ( sv.find_first_of( needle ), i );
}
std::reverse( str, str + 256 );
for( int i = 0; i < 256; ++i )
{
std::wstring needle( 12, static_cast< wchar_t >( 0x100 + i ) );
BOOST_TEST_EQ( sv.find_first_of( needle ), 255 - i );
}
}
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
{
boost::core::u8string_view sv( u8"123123" );
BOOST_TEST_EQ( sv.find_last_of( u8"", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"", 6 ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"", 7 ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"" ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"1", 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( u8"1", 1 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( u8"1", 2 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( u8"1", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"1", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"1", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"1", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"1", 7 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"1" ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"23", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"23", 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( u8"23", 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( u8"23", 3 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( u8"23", 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( u8"23", 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( u8"23", 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( u8"23", 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( u8"23" ), 5 );
BOOST_TEST_EQ( sv.find_last_of( u8"123", 0 ), 0 );
BOOST_TEST_EQ( sv.find_last_of( u8"123", 1 ), 1 );
BOOST_TEST_EQ( sv.find_last_of( u8"123", 2 ), 2 );
BOOST_TEST_EQ( sv.find_last_of( u8"123", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"123", 4 ), 4 );
BOOST_TEST_EQ( sv.find_last_of( u8"123", 5 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( u8"123", 6 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( u8"123", 7 ), 5 );
BOOST_TEST_EQ( sv.find_last_of( u8"123" ), 5 );
}
{
boost::core::u8string_view sv( u8"abc1abc2abc3" );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( u8"0123456789" ), 11 );
}
{
boost::core::u8string_view sv( u8"123a123B123c" );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 0 ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 1 ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 2 ), npos );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 3 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 4 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 5 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 6 ), 3 );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 7 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 8 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 9 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 10 ), 7 );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 11 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), 11 );
BOOST_TEST_EQ( sv.find_last_of( u8"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), 11 );
}
#endif
return boost::report_errors();
}

130
test/sv_find_test.cpp Normal file
View File

@@ -0,0 +1,130 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
int main()
{
std::size_t const npos = boost::core::string_view::npos;
{
boost::core::string_view sv( "" );
BOOST_TEST_EQ( sv.find( boost::core::string_view() ), 0 );
BOOST_TEST_EQ( sv.find( boost::core::string_view(), 1 ), npos );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "" ) ), 0 );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "" ), 1 ), npos );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "1" ) ), npos );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "1" ), 1 ), npos );
BOOST_TEST_EQ( sv.find( '1' ), npos );
BOOST_TEST_EQ( sv.find( '1', 1 ), npos );
BOOST_TEST_EQ( sv.find( "" ), 0 );
BOOST_TEST_EQ( sv.find( "", 1 ), npos );
BOOST_TEST_EQ( sv.find( "1" ), npos );
BOOST_TEST_EQ( sv.find( "1", 1 ), npos );
BOOST_TEST_EQ( sv.find( "1", 0, 0 ), 0 );
BOOST_TEST_EQ( sv.find( "1", 1, 0 ), npos );
BOOST_TEST_EQ( sv.find( "1", 0, 1 ), npos );
BOOST_TEST_EQ( sv.find( "1", 1, 1 ), npos );
}
{
boost::core::string_view sv( "123123" );
BOOST_TEST_EQ( sv.find( boost::core::string_view() ), 0 );
BOOST_TEST_EQ( sv.find( boost::core::string_view(), 1 ), 1 );
BOOST_TEST_EQ( sv.find( boost::core::string_view(), 6 ), 6 );
BOOST_TEST_EQ( sv.find( boost::core::string_view(), 7 ), npos );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "" ) ), 0 );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "" ), 6 ), 6 );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "" ), 7 ), npos );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "1" ) ), 0 );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "1" ), 1 ), 3 );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "1" ), 3 ), 3 );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "1" ), 4 ), npos );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "1" ), 6 ), npos );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "1" ), 7 ), npos );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "23" ) ), 1 );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "23" ), 1 ), 1 );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "23" ), 2 ), 4 );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "23" ), 4 ), 4 );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "23" ), 5 ), npos );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "23" ), 6 ), npos );
BOOST_TEST_EQ( sv.find( boost::core::string_view( "23" ), 7 ), npos );
BOOST_TEST_EQ( sv.find( '1' ), 0 );
BOOST_TEST_EQ( sv.find( '1', 1 ), 3 );
BOOST_TEST_EQ( sv.find( '1', 2 ), 3 );
BOOST_TEST_EQ( sv.find( '1', 3 ), 3 );
BOOST_TEST_EQ( sv.find( '1', 4 ), npos );
BOOST_TEST_EQ( sv.find( '1', 5 ), npos );
BOOST_TEST_EQ( sv.find( '1', 6 ), npos );
BOOST_TEST_EQ( sv.find( '1', 7 ), npos );
BOOST_TEST_EQ( sv.find( '3' ), 2 );
BOOST_TEST_EQ( sv.find( '3', 1 ), 2 );
BOOST_TEST_EQ( sv.find( '3', 2 ), 2 );
BOOST_TEST_EQ( sv.find( '3', 3 ), 5 );
BOOST_TEST_EQ( sv.find( '3', 4 ), 5 );
BOOST_TEST_EQ( sv.find( '3', 5 ), 5 );
BOOST_TEST_EQ( sv.find( '3', 6 ), npos );
BOOST_TEST_EQ( sv.find( '3', 7 ), npos );
BOOST_TEST_EQ( sv.find( '9' ), npos );
BOOST_TEST_EQ( sv.find( "" ), 0 );
BOOST_TEST_EQ( sv.find( "", 1 ), 1 );
BOOST_TEST_EQ( sv.find( "", 6 ), 6 );
BOOST_TEST_EQ( sv.find( "", 7 ), npos );
BOOST_TEST_EQ( sv.find( "1" ), 0 );
BOOST_TEST_EQ( sv.find( "1", 1 ), 3 );
BOOST_TEST_EQ( sv.find( "1", 3 ), 3 );
BOOST_TEST_EQ( sv.find( "1", 4 ), npos );
BOOST_TEST_EQ( sv.find( "1", 6 ), npos );
BOOST_TEST_EQ( sv.find( "1", 7 ), npos );
BOOST_TEST_EQ( sv.find( "23" ), 1 );
BOOST_TEST_EQ( sv.find( "23", 1 ), 1 );
BOOST_TEST_EQ( sv.find( "23", 2 ), 4 );
BOOST_TEST_EQ( sv.find( "23", 4 ), 4 );
BOOST_TEST_EQ( sv.find( "23", 5 ), npos );
BOOST_TEST_EQ( sv.find( "23", 6 ), npos );
BOOST_TEST_EQ( sv.find( "23", 7 ), npos );
BOOST_TEST_EQ( sv.find( "123", 0, 0 ), 0 );
BOOST_TEST_EQ( sv.find( "123", 1, 0 ), 1 );
BOOST_TEST_EQ( sv.find( "123", 6, 0 ), 6 );
BOOST_TEST_EQ( sv.find( "123", 7, 0 ), npos );
BOOST_TEST_EQ( sv.find( "123", 0, 1 ), 0 );
BOOST_TEST_EQ( sv.find( "123", 1, 1 ), 3 );
BOOST_TEST_EQ( sv.find( "123", 3, 1 ), 3 );
BOOST_TEST_EQ( sv.find( "123", 4, 1 ), npos );
BOOST_TEST_EQ( sv.find( "123", 6, 1 ), npos );
BOOST_TEST_EQ( sv.find( "123", 7, 1 ), npos );
BOOST_TEST_EQ( sv.find( "123", 0, 3 ), 0 );
BOOST_TEST_EQ( sv.find( "123", 1, 3 ), 3 );
BOOST_TEST_EQ( sv.find( "123", 3, 3 ), 3 );
BOOST_TEST_EQ( sv.find( "123", 4, 3 ), npos );
BOOST_TEST_EQ( sv.find( "123", 6, 3 ), npos );
BOOST_TEST_EQ( sv.find( "123", 7, 3 ), npos );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,61 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <string>
#include <algorithm>
int main()
{
{
boost::core::string_view sv;
{
std::string s( sv.begin(), sv.end() );
BOOST_TEST_EQ( s, std::string( "" ) );
}
{
std::string s( sv.cbegin(), sv.cend() );
BOOST_TEST_EQ( s, std::string( "" ) );
}
{
std::string s( sv.rbegin(), sv.rend() );
BOOST_TEST_EQ( s, std::string( "" ) );
}
{
std::string s( sv.crbegin(), sv.crend() );
BOOST_TEST_EQ( s, std::string( "" ) );
}
}
{
boost::core::string_view sv( "123" );
{
std::string s( sv.begin(), sv.end() );
BOOST_TEST_EQ( s, std::string( "123" ) );
}
{
std::string s( sv.cbegin(), sv.cend() );
BOOST_TEST_EQ( s, std::string( "123" ) );
}
{
std::string s( sv.rbegin(), sv.rend() );
BOOST_TEST_EQ( s, std::string( "321" ) );
}
{
std::string s( sv.crbegin(), sv.crend() );
BOOST_TEST_EQ( s, std::string( "321" ) );
}
}
return boost::report_errors();
}

109
test/sv_lt_test.cpp Normal file
View File

@@ -0,0 +1,109 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
# include <string_view>
#endif
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
# include <memory_resource>
#endif
#define TEST_LT(x, y) \
BOOST_TEST_LT(x, y); \
BOOST_TEST_LE(x, y); \
BOOST_TEST_NE(x, y); \
BOOST_TEST_NOT((x) == (y)); \
BOOST_TEST_NOT((x) >= (y)); \
BOOST_TEST_NOT((x) > (y)); \
BOOST_TEST_GT(y, x); \
BOOST_TEST_GE(y, x); \
BOOST_TEST_NOT((y) < (x)); \
BOOST_TEST_NOT((y) <= (x));
int main()
{
{
boost::core::string_view sv0( "" );
boost::core::string_view sv1( "12" );
boost::core::string_view sv2( "122" );
boost::core::string_view sv3( "123" );
boost::core::string_view sv4( "124" );
boost::core::string_view sv5( "1234" );
TEST_LT( sv0, sv1 );
TEST_LT( sv1, sv2 );
TEST_LT( sv2, sv3 );
TEST_LT( sv3, sv4 );
TEST_LT( sv3, sv5 );
TEST_LT( sv5, sv4 );
TEST_LT( sv0, std::string( "12" ) );
TEST_LT( sv1, std::string( "122" ) );
TEST_LT( sv2, std::string( "123" ) );
TEST_LT( sv3, std::string( "124" ) );
TEST_LT( sv3, std::string( "1234" ) );
TEST_LT( sv5, std::string( "124" ) );
TEST_LT( sv0, "12" );
TEST_LT( sv1, "122" );
TEST_LT( sv2, "123" );
TEST_LT( sv3, "124" );
TEST_LT( sv3, "1234" );
TEST_LT( sv5, "124" );
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
TEST_LT( sv0, std::string_view( "12" ) );
TEST_LT( sv1, std::string_view( "122" ) );
TEST_LT( sv2, std::string_view( "123" ) );
TEST_LT( sv3, std::string_view( "124" ) );
TEST_LT( sv3, std::string_view( "1234" ) );
TEST_LT( sv5, std::string_view( "124" ) );
#endif
TEST_LT( std::string( "" ), sv1 );
TEST_LT( std::string( "12" ), sv2 );
TEST_LT( std::string( "122" ), sv3 );
TEST_LT( std::string( "123" ), sv4 );
TEST_LT( std::string( "123" ), sv5 );
TEST_LT( std::string( "1234" ), sv4 );
TEST_LT( "", sv1 );
TEST_LT( "12", sv2 );
TEST_LT( "122", sv3 );
TEST_LT( "123", sv4 );
TEST_LT( "123", sv5 );
TEST_LT( "1234", sv4 );
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
TEST_LT( std::string_view( "" ), sv1 );
TEST_LT( std::string_view( "12" ), sv2 );
TEST_LT( std::string_view( "122" ), sv3 );
TEST_LT( std::string_view( "123" ), sv4 );
TEST_LT( std::string_view( "123" ), sv5 );
TEST_LT( std::string_view( "1234" ), sv4 );
#endif
#if !defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
using pmr_string = std::basic_string<char, std::char_traits<char>, std::pmr::polymorphic_allocator<char>>;
TEST_LT( pmr_string( "" ), sv1 );
TEST_LT( pmr_string( "12" ), sv2 );
TEST_LT( pmr_string( "122" ), sv3 );
TEST_LT( pmr_string( "123" ), sv4 );
TEST_LT( pmr_string( "123" ), sv5 );
TEST_LT( pmr_string( "1234" ), sv4 );
#endif
}
return boost::report_errors();
}

127
test/sv_modifiers_test.cpp Normal file
View File

@@ -0,0 +1,127 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
int main()
{
{
char const* s1 = "12345";
char const* s2 = "";
boost::core::string_view sv1( s1 );
boost::core::string_view sv2( s2 );
sv1.swap( sv2 );
BOOST_TEST_EQ( sv1.data(), s2 );
BOOST_TEST_EQ( sv1.size(), 0 );
BOOST_TEST_EQ( sv2.data(), s1 );
BOOST_TEST_EQ( sv2.size(), 5);
}
{
boost::core::string_view sv;
char const* data = sv.data();
std::size_t size = sv.size();
sv.remove_prefix( 0 );
BOOST_TEST_EQ( sv.data(), data );
BOOST_TEST_EQ( sv.size(), size );
sv.remove_suffix( 0 );
BOOST_TEST_EQ( sv.data(), data );
BOOST_TEST_EQ( sv.size(), size );
}
{
boost::core::string_view sv( "" );
char const* data = sv.data();
std::size_t size = sv.size();
sv.remove_prefix( 0 );
BOOST_TEST_EQ( sv.data(), data );
BOOST_TEST_EQ( sv.size(), size );
sv.remove_suffix( 0 );
BOOST_TEST_EQ( sv.data(), data );
BOOST_TEST_EQ( sv.size(), size );
}
{
boost::core::string_view sv( "12345" );
char const* data = sv.data();
std::size_t size = sv.size();
sv.remove_prefix( 0 );
BOOST_TEST_EQ( sv.data(), data );
BOOST_TEST_EQ( sv.size(), size );
sv.remove_suffix( 0 );
BOOST_TEST_EQ( sv.data(), data );
BOOST_TEST_EQ( sv.size(), size );
}
{
boost::core::string_view sv( "12345" );
char const* data = sv.data();
std::size_t size = sv.size();
sv.remove_prefix( 2 );
BOOST_TEST_EQ( sv.data(), data + 2 );
BOOST_TEST_EQ( sv.size(), size - 2 );
}
{
boost::core::string_view sv( "12345" );
char const* data = sv.data();
std::size_t size = sv.size();
sv.remove_prefix( 5 );
BOOST_TEST_EQ( sv.data(), data + 5 );
BOOST_TEST_EQ( sv.size(), size - 5 );
}
{
boost::core::string_view sv( "12345" );
char const* data = sv.data();
std::size_t size = sv.size();
sv.remove_suffix( 2 );
BOOST_TEST_EQ( sv.data(), data );
BOOST_TEST_EQ( sv.size(), size - 2 );
}
{
boost::core::string_view sv( "12345" );
char const* data = sv.data();
std::size_t size = sv.size();
sv.remove_suffix( 5 );
BOOST_TEST_EQ( sv.data(), data );
BOOST_TEST_EQ( sv.size(), size - 5 );
}
return boost::report_errors();
}

169
test/sv_rfind_test.cpp Normal file
View File

@@ -0,0 +1,169 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
int main()
{
std::size_t const npos = boost::core::string_view::npos;
{
boost::core::string_view sv( "" );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view() ), 0 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view(), 1 ), 0 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view(), 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "" ) ), 0 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "" ), 1 ), 0 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "" ), 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ) ), npos );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ), 1 ), npos );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ), 0 ), npos );
BOOST_TEST_EQ( sv.rfind( '1' ), npos );
BOOST_TEST_EQ( sv.rfind( '1', 1 ), npos );
BOOST_TEST_EQ( sv.rfind( '1', 0 ), npos );
BOOST_TEST_EQ( sv.rfind( "" ), 0 );
BOOST_TEST_EQ( sv.rfind( "", 1 ), 0 );
BOOST_TEST_EQ( sv.rfind( "", 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( "1" ), npos );
BOOST_TEST_EQ( sv.rfind( "1", 1 ), npos );
BOOST_TEST_EQ( sv.rfind( "1", 0 ), npos );
BOOST_TEST_EQ( sv.rfind( "1", npos, 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( "1", 1, 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( "1", 0, 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( "1", npos, 1 ), npos );
BOOST_TEST_EQ( sv.rfind( "1", 1, 1 ), npos );
BOOST_TEST_EQ( sv.rfind( "1", 0, 1 ), npos );
}
{
boost::core::string_view sv( "123123" );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view() ), 6 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view(), 7 ), 6 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view(), 6 ), 6 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view(), 5 ), 5 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view(), 1 ), 1 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view(), 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "" ) ), 6 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "" ), 7 ), 6 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "" ), 6 ), 6 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "" ), 5 ), 5 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "" ), 1 ), 1 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "" ), 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ) ), 3 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ), 7 ), 3 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ), 6 ), 3 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ), 5 ), 3 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ), 4 ), 3 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ), 3 ), 3 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ), 2 ), 0 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ), 1 ), 0 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "1" ), 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "23" ) ), 4 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "23" ), 7 ), 4 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "23" ), 6 ), 4 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "23" ), 5 ), 4 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "23" ), 4 ), 4 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "23" ), 3 ), 1 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "23" ), 2 ), 1 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "23" ), 1 ), 1 );
BOOST_TEST_EQ( sv.rfind( boost::core::string_view( "23" ), 0 ), npos );
BOOST_TEST_EQ( sv.rfind( '1' ), 3 );
BOOST_TEST_EQ( sv.rfind( '1', 7 ), 3 );
BOOST_TEST_EQ( sv.rfind( '1', 6 ), 3 );
BOOST_TEST_EQ( sv.rfind( '1', 5 ), 3 );
BOOST_TEST_EQ( sv.rfind( '1', 4 ), 3 );
BOOST_TEST_EQ( sv.rfind( '1', 3 ), 3 );
BOOST_TEST_EQ( sv.rfind( '1', 2 ), 0 );
BOOST_TEST_EQ( sv.rfind( '1', 1 ), 0 );
BOOST_TEST_EQ( sv.rfind( '1', 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( '3' ), 5 );
BOOST_TEST_EQ( sv.rfind( '3', 7 ), 5 );
BOOST_TEST_EQ( sv.rfind( '3', 6 ), 5 );
BOOST_TEST_EQ( sv.rfind( '3', 5 ), 5 );
BOOST_TEST_EQ( sv.rfind( '3', 4 ), 2 );
BOOST_TEST_EQ( sv.rfind( '3', 3 ), 2 );
BOOST_TEST_EQ( sv.rfind( '3', 2 ), 2 );
BOOST_TEST_EQ( sv.rfind( '3', 1 ), npos );
BOOST_TEST_EQ( sv.rfind( '3', 0 ), npos );
BOOST_TEST_EQ( sv.rfind( '9' ), npos );
BOOST_TEST_EQ( sv.rfind( '9', 7 ), npos );
BOOST_TEST_EQ( sv.rfind( '9', 6 ), npos );
BOOST_TEST_EQ( sv.rfind( "" ), 6 );
BOOST_TEST_EQ( sv.rfind( "", 7 ), 6 );
BOOST_TEST_EQ( sv.rfind( "", 6 ), 6 );
BOOST_TEST_EQ( sv.rfind( "", 5 ), 5 );
BOOST_TEST_EQ( sv.rfind( "", 1 ), 1 );
BOOST_TEST_EQ( sv.rfind( "", 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( "1" ), 3 );
BOOST_TEST_EQ( sv.rfind( "1", 7 ), 3 );
BOOST_TEST_EQ( sv.rfind( "1", 6 ), 3 );
BOOST_TEST_EQ( sv.rfind( "1", 5 ), 3 );
BOOST_TEST_EQ( sv.rfind( "1", 4 ), 3 );
BOOST_TEST_EQ( sv.rfind( "1", 3 ), 3 );
BOOST_TEST_EQ( sv.rfind( "1", 2 ), 0 );
BOOST_TEST_EQ( sv.rfind( "1", 1 ), 0 );
BOOST_TEST_EQ( sv.rfind( "1", 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( "23" ), 4 );
BOOST_TEST_EQ( sv.rfind( "23", 7 ), 4 );
BOOST_TEST_EQ( sv.rfind( "23", 6 ), 4 );
BOOST_TEST_EQ( sv.rfind( "23", 5 ), 4 );
BOOST_TEST_EQ( sv.rfind( "23", 4 ), 4 );
BOOST_TEST_EQ( sv.rfind( "23", 3 ), 1 );
BOOST_TEST_EQ( sv.rfind( "23", 2 ), 1 );
BOOST_TEST_EQ( sv.rfind( "23", 1 ), 1 );
BOOST_TEST_EQ( sv.rfind( "23", 0 ), npos );
BOOST_TEST_EQ( sv.rfind( "123", npos, 0 ), 6 );
BOOST_TEST_EQ( sv.rfind( "123", 7, 0 ), 6 );
BOOST_TEST_EQ( sv.rfind( "123", 6, 0 ), 6 );
BOOST_TEST_EQ( sv.rfind( "123", 5, 0 ), 5 );
BOOST_TEST_EQ( sv.rfind( "123", 1, 0 ), 1 );
BOOST_TEST_EQ( sv.rfind( "123", 0, 0 ), 0 );
BOOST_TEST_EQ( sv.rfind( "123", npos, 1 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 7, 1 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 6, 1 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 5, 1 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 4, 1 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 3, 1 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 2, 1 ), 0 );
BOOST_TEST_EQ( sv.rfind( "123", 1, 1 ), 0 );
BOOST_TEST_EQ( sv.rfind( "123", 0, 1 ), 0 );
BOOST_TEST_EQ( sv.rfind( "123", npos, 3 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 7, 3 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 6, 3 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 5, 3 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 4, 3 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 3, 3 ), 3 );
BOOST_TEST_EQ( sv.rfind( "123", 2, 3 ), 0 );
BOOST_TEST_EQ( sv.rfind( "123", 1, 3 ), 0 );
BOOST_TEST_EQ( sv.rfind( "123", 0, 3 ), 0 );
BOOST_TEST_EQ( sv.rfind( "123123" ), 0 );
BOOST_TEST_EQ( sv.rfind( "1231231" ), npos );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,50 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept>
#include <cstddef>
int main()
{
{
boost::core::string_view sv( "" );
BOOST_TEST( sv.starts_with( boost::core::string_view() ) );
BOOST_TEST( sv.starts_with( boost::core::string_view( "" ) ) );
BOOST_TEST( sv.starts_with( "" ) );
BOOST_TEST( !sv.starts_with( boost::core::string_view( "1" ) ) );
BOOST_TEST( !sv.starts_with( '1' ) );
BOOST_TEST( !sv.starts_with( "1" ) );
}
{
boost::core::string_view sv( "123" );
BOOST_TEST( sv.starts_with( boost::core::string_view() ) );
BOOST_TEST( sv.starts_with( boost::core::string_view( "" ) ) );
BOOST_TEST( sv.starts_with( "" ) );
BOOST_TEST( sv.starts_with( boost::core::string_view( "1" ) ) );
BOOST_TEST( sv.starts_with( '1' ) );
BOOST_TEST( sv.starts_with( "1" ) );
BOOST_TEST( sv.starts_with( boost::core::string_view( "12" ) ) );
BOOST_TEST( sv.starts_with( "12" ) );
BOOST_TEST( sv.starts_with( boost::core::string_view( "123" ) ) );
BOOST_TEST( sv.starts_with( "123" ) );
BOOST_TEST( !sv.starts_with( boost::core::string_view( "1234" ) ) );
BOOST_TEST( !sv.starts_with( "1234" ) );
BOOST_TEST( !sv.starts_with( boost::core::string_view( "2" ) ) );
BOOST_TEST( !sv.starts_with( '2' ) );
BOOST_TEST( !sv.starts_with( "2" ) );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,111 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <sstream>
#include <iomanip>
int main()
{
using boost::core::string_view;
{
std::ostringstream os;
os << string_view( "" );
BOOST_TEST_EQ( os.str(), std::string( "" ) );
}
{
std::ostringstream os;
os << string_view( "123" );
BOOST_TEST_EQ( os.str(), std::string( "123" ) );
}
{
std::ostringstream os;
os << std::setw( 5 ) << string_view( "" );
BOOST_TEST_EQ( os.str(), std::string( " " ) );
}
{
std::ostringstream os;
os << std::setfill( '-' ) << std::setw( 5 ) << string_view( "" );
BOOST_TEST_EQ( os.str(), std::string( "-----" ) );
}
{
std::ostringstream os;
os << std::setw( 5 ) << string_view( "123" );
BOOST_TEST_EQ( os.str(), std::string( " 123" ) );
}
{
std::ostringstream os;
os << std::left << std::setw( 5 ) << string_view( "123" );
BOOST_TEST_EQ( os.str(), std::string( "123 " ) );
}
{
std::ostringstream os;
os << std::right << std::setw( 5 ) << string_view( "123" );
BOOST_TEST_EQ( os.str(), std::string( " 123" ) );
}
{
std::ostringstream os;
os << std::setfill( '-' ) << std::setw( 5 ) << string_view( "123" );
BOOST_TEST_EQ( os.str(), std::string( "--123" ) );
}
{
std::ostringstream os;
os << std::setfill( '-' ) << std::left << std::setw( 5 ) << string_view( "123" );
BOOST_TEST_EQ( os.str(), std::string( "123--" ) );
}
{
std::ostringstream os;
os << std::setfill( '-' ) << std::right << std::setw( 5 ) << string_view( "123" );
BOOST_TEST_EQ( os.str(), std::string( "--123" ) );
}
{
std::ostringstream os;
os << std::setw( 5 ) << string_view( "12345" );
BOOST_TEST_EQ( os.str(), std::string( "12345" ) );
}
{
std::ostringstream os;
os << std::setw( 5 ) << string_view( "1234567" );
BOOST_TEST_EQ( os.str(), std::string( "1234567" ) );
}
return boost::report_errors();
}

203
test/sv_substr_test.cpp Normal file
View File

@@ -0,0 +1,203 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept>
#include <cstddef>
int main()
{
{
boost::core::string_view sv;
{
boost::core::string_view sv2 = sv.substr();
BOOST_TEST_EQ( sv2.data(), sv.data() );
BOOST_TEST_EQ( sv2.size(), sv.size() );
}
{
boost::core::string_view sv2 = sv.substr( 0 );
BOOST_TEST_EQ( sv2.data(), sv.data() );
BOOST_TEST_EQ( sv2.size(), sv.size() );
}
BOOST_TEST_THROWS( sv.substr( 1 ), std::out_of_range );
BOOST_TEST_THROWS( sv.substr( boost::core::string_view::npos ), std::out_of_range );
{
boost::core::string_view sv2 = sv.substr( 0, 1 );
BOOST_TEST_EQ( sv2.data(), sv.data() );
BOOST_TEST_EQ( sv2.size(), sv.size() );
}
{
boost::core::string_view sv2 = sv.substr( 0, 0 );
BOOST_TEST_EQ( sv2.data(), sv.data() );
BOOST_TEST_EQ( sv2.size(), sv.size() );
}
BOOST_TEST_THROWS( sv.substr( 1, 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv.substr( boost::core::string_view::npos, 0 ), std::out_of_range );
}
{
boost::core::string_view sv( "12345" );
{
boost::core::string_view sv2 = sv.substr();
BOOST_TEST_EQ( sv2.data(), sv.data() );
BOOST_TEST_EQ( sv2.size(), sv.size() );
}
{
boost::core::string_view sv2 = sv.substr( 0 );
BOOST_TEST_EQ( sv2.data(), sv.data() );
BOOST_TEST_EQ( sv2.size(), sv.size() );
}
{
boost::core::string_view sv2 = sv.substr( 2 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 2 );
BOOST_TEST_EQ( sv2.size(), sv.size() - 2 );
}
{
boost::core::string_view sv2 = sv.substr( 5 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 5 );
BOOST_TEST_EQ( sv2.size(), sv.size() - 5 );
}
BOOST_TEST_THROWS( sv.substr( 6 ), std::out_of_range );
BOOST_TEST_THROWS( sv.substr( boost::core::string_view::npos ), std::out_of_range );
{
boost::core::string_view sv2 = sv.substr( 0, 0 );
BOOST_TEST_EQ( sv2.data(), sv.data() );
BOOST_TEST_EQ( sv2.size(), 0 );
}
{
boost::core::string_view sv2 = sv.substr( 2, 0 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 2 );
BOOST_TEST_EQ( sv2.size(), 0 );
}
{
boost::core::string_view sv2 = sv.substr( 5, 0 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 5 );
BOOST_TEST_EQ( sv2.size(), 0 );
}
BOOST_TEST_THROWS( sv.substr( 6, 0 ), std::out_of_range );
BOOST_TEST_THROWS( sv.substr( boost::core::string_view::npos, 0 ), std::out_of_range );
{
boost::core::string_view sv2 = sv.substr( 0, 3 );
BOOST_TEST_EQ( sv2.data(), sv.data() );
BOOST_TEST_EQ( sv2.size(), 3 );
}
{
boost::core::string_view sv2 = sv.substr( 2, 3 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 2 );
BOOST_TEST_EQ( sv2.size(), 3 );
}
{
boost::core::string_view sv2 = sv.substr( 4, 3 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 4 );
BOOST_TEST_EQ( sv2.size(), 1 );
}
{
boost::core::string_view sv2 = sv.substr( 5, 3 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 5 );
BOOST_TEST_EQ( sv2.size(), 0 );
}
BOOST_TEST_THROWS( sv.substr( 6, 3 ), std::out_of_range );
BOOST_TEST_THROWS( sv.substr( boost::core::string_view::npos, 3 ), std::out_of_range );
{
boost::core::string_view sv2 = sv.substr( 0, 5 );
BOOST_TEST_EQ( sv2.data(), sv.data() );
BOOST_TEST_EQ( sv2.size(), 5 );
}
{
boost::core::string_view sv2 = sv.substr( 2, 5 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 2 );
BOOST_TEST_EQ( sv2.size(), 3 );
}
{
boost::core::string_view sv2 = sv.substr( 4, 5 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 4 );
BOOST_TEST_EQ( sv2.size(), 1 );
}
{
boost::core::string_view sv2 = sv.substr( 5, 5 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 5 );
BOOST_TEST_EQ( sv2.size(), 0 );
}
BOOST_TEST_THROWS( sv.substr( 6, 5 ), std::out_of_range );
BOOST_TEST_THROWS( sv.substr( boost::core::string_view::npos, 5 ), std::out_of_range );
{
boost::core::string_view sv2 = sv.substr( 0, 8 );
BOOST_TEST_EQ( sv2.data(), sv.data() );
BOOST_TEST_EQ( sv2.size(), 5 );
}
{
boost::core::string_view sv2 = sv.substr( 2, 8 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 2 );
BOOST_TEST_EQ( sv2.size(), 3 );
}
{
boost::core::string_view sv2 = sv.substr( 4, 8 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 4 );
BOOST_TEST_EQ( sv2.size(), 1 );
}
{
boost::core::string_view sv2 = sv.substr( 5, 8 );
BOOST_TEST_EQ( sv2.data(), sv.data() + 5 );
BOOST_TEST_EQ( sv2.size(), 0 );
}
BOOST_TEST_THROWS( sv.substr( 6, 8 ), std::out_of_range );
BOOST_TEST_THROWS( sv.substr( boost::core::string_view::npos, 8 ), std::out_of_range );
}
return boost::report_errors();
}

47
test/sv_types_test.cpp Normal file
View File

@@ -0,0 +1,47 @@
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/core/is_same.hpp>
#include <iterator>
struct Ch
{
};
int main()
{
typedef boost::core::basic_string_view<Ch> ch_string_view;
BOOST_TEST_TRAIT_SAME(ch_string_view::traits_type, std::char_traits<Ch>);
BOOST_TEST_TRAIT_SAME(ch_string_view::value_type, Ch);
BOOST_TEST_TRAIT_SAME(ch_string_view::pointer, Ch*);
BOOST_TEST_TRAIT_SAME(ch_string_view::const_pointer, Ch const*);
BOOST_TEST_TRAIT_SAME(ch_string_view::reference, Ch&);
BOOST_TEST_TRAIT_SAME(ch_string_view::const_reference, Ch const&);
BOOST_TEST_TRAIT_SAME(ch_string_view::iterator, ch_string_view::const_iterator);
BOOST_TEST_TRAIT_SAME(std::iterator_traits<ch_string_view::iterator>::iterator_category, std::random_access_iterator_tag);
BOOST_TEST_TRAIT_SAME(ch_string_view::reverse_iterator, ch_string_view::const_reverse_iterator);
BOOST_TEST_TRAIT_SAME(ch_string_view::reverse_iterator, std::reverse_iterator<ch_string_view::iterator>);
BOOST_TEST_TRAIT_SAME(ch_string_view::size_type, std::size_t);
BOOST_TEST_TRAIT_SAME(ch_string_view::difference_type, std::ptrdiff_t);
BOOST_TEST_EQ(ch_string_view::npos, static_cast<std::size_t>(-1));
BOOST_TEST_TRAIT_SAME(boost::core::string_view, boost::core::basic_string_view<char>);
BOOST_TEST_TRAIT_SAME(boost::core::wstring_view, boost::core::basic_string_view<wchar_t>);
#if !defined(BOOST_NO_CXX11_CHAR16_T)
BOOST_TEST_TRAIT_SAME(boost::core::u16string_view, boost::core::basic_string_view<char16_t>);
#endif
#if !defined(BOOST_NO_CXX11_CHAR32_T)
BOOST_TEST_TRAIT_SAME(boost::core::u32string_view, boost::core::basic_string_view<char32_t>);
#endif
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
BOOST_TEST_TRAIT_SAME(boost::core::u8string_view, boost::core::basic_string_view<char8_t>);
#endif
return boost::report_errors();
}

View File

@@ -17,6 +17,10 @@
#include <algorithm> //for std::copy and std::equal
#include <cstddef> //for std::size_t
#if defined(__clang__)
# pragma clang diagnostic ignored "-Wunused-function"
#endif
//Provide swap function in both the namespace of swap_test_class
//(which is the global namespace), and the std namespace.
//It's common to provide a swap function for a class in both

View File

@@ -17,6 +17,10 @@
#include <algorithm> //for std::copy and std::equal
#include <cstddef> //for std::size_t
#if defined(__clang__)
# pragma clang diagnostic ignored "-Wunused-function"
#endif
//Provide swap function in both the namespace of swap_test_class
//(which is the global namespace), and the std namespace.
//It's common to provide a swap function for a class in both

View File

@@ -50,8 +50,8 @@ void swap(swap_test_template<T>& left, swap_test_template<T>& right)
int main()
{
const std::size_t array_size = 2;
const swap_test_template<int> initial_array1[array_size] = { swap_test_class(1), swap_test_class(2) };
const swap_test_template<int> initial_array2[array_size] = { swap_test_class(3), swap_test_class(4) };
const swap_test_template<int> initial_array1[array_size] = { { swap_test_class(1) }, { swap_test_class(2) } };
const swap_test_template<int> initial_array2[array_size] = { { swap_test_class(3) }, { swap_test_class(4) } };
swap_test_template<int> array1[array_size];
swap_test_template<int> array2[array_size];

View File

@@ -124,7 +124,7 @@ struct pointer_traits<P6<T> > {
namespace std {
template<class T>
struct pointer_traits<P6<T> > {
static T* to_address(const P6<T>& p) BOOST_NOEXCEPT {
static T* to_address(const P6<T>& /*p*/) BOOST_NOEXCEPT {
return 0;
}
};

View File

@@ -27,6 +27,10 @@
# include <array>
#endif
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)
# include <tuple>
#endif
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
# include <string_view>
#endif
@@ -203,7 +207,7 @@ int main()
TEST(A volatile[]);
TEST(A const volatile[]);
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1500
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1700
TEST(A(&)[]);
#endif
TEST(A const(***)[]);
@@ -219,7 +223,7 @@ int main()
TEST(A[][2][3]);
TEST(A const[][2][3]);
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1500
#if !defined(BOOST_MSVC) || BOOST_MSVC >= 1700
TEST(A(&)[][2][3]);
#endif
TEST(A const(***)[][2][3]);
@@ -265,6 +269,9 @@ int main()
TEST(std::pair<A, B>);
TEST(std::pair<A const*, B*> volatile&);
TEST(std::pair<void, void>);
TEST(std::pair<std::pair<void, void>, void>);
TEST(std::basic_string<Ch>);
TEST(std::string);
@@ -286,6 +293,8 @@ int main()
TEST(X<A, B>);
TEST(X<A const&, B&> volatile&);
TEST(X<std::pair<void, void>, void>);
TEST(std::vector<int>);
TEST(std::vector<A>);
TEST(std::vector<std::string>);
@@ -326,6 +335,23 @@ int main()
TEST(std::array<std::string, 7>);
TEST(std::array<std::wstring const*, 0> const&);
#endif
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && ( !defined(BOOST_MSVC) || BOOST_MSVC >= 1700 )
TEST(std::tuple<>);
TEST(std::tuple<int>);
TEST(std::tuple<int, float>);
TEST(std::tuple<int, float, std::string>);
TEST(std::tuple<void>);
TEST(std::tuple<void, void>);
TEST(std::tuple<void, void, void>);
TEST(std::tuple<std::tuple<void, void>, void>);
TEST(X<std::tuple<void>, void>);
#endif
TEST(std::ostream);

View File

@@ -18,6 +18,10 @@
#include <boost/core/uncaught_exceptions.hpp>
#include <boost/core/lightweight_test.hpp>
#if defined(_MSC_VER)
# pragma warning(disable: 4512) // assignment operator could not be generated
#endif
struct my_exception {};
class exception_watcher

View File

@@ -20,6 +20,10 @@
#include <boost/core/lightweight_test.hpp>
#if defined(_MSC_VER)
# pragma warning(disable: 4512) // assignment operator could not be generated
#endif
struct my_exception1 {};
struct my_exception2 {};

View File

@@ -18,6 +18,10 @@
#include <boost/core/is_same.hpp>
#include <boost/config.hpp>
#if defined(_MSC_VER)
# pragma warning(disable: 4244) // conversion from enum_type to underlying_type
#endif
BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(emulated_enum, unsigned char)
{
value0,

View File

@@ -11,5 +11,5 @@ Distributed under the Boost Software License, Version 1.0.
template<class, class = boost::use_default>
struct type { };
template class type<int>;
template class type<void, boost::use_default>;
template struct type<int>;
template struct type<void, boost::use_default>;

View File

@@ -34,7 +34,7 @@ struct V
{
}
template< class T > void operator()( T const & t )
template< class T > void operator()( T const & /*t*/ )
{
}
@@ -45,7 +45,7 @@ struct V
void operator()( std::string const & w )
{
s_ = s_ * 10 + w.size();
s_ = s_ * 10 + static_cast<int>( w.size() );
}
};