mirror of
https://github.com/boostorg/core.git
synced 2026-05-07 08:56:39 +02:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cc765abfc6 | |||
| b7fdbf41a7 | |||
| 5bea3b85e6 | |||
| b0bae8a8ae | |||
| 99d550a5e4 | |||
| 239953da9f | |||
| 52831a4fd9 | |||
| b852430614 | |||
| ed46bfacff | |||
| 6afe70e09d |
+21
-24
@@ -151,20 +151,6 @@ jobs:
|
||||
- g++-12
|
||||
|
||||
# Linux, clang
|
||||
- toolset: clang
|
||||
compiler: clang++-3.5
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.5
|
||||
- toolset: clang
|
||||
compiler: clang++-3.6
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install:
|
||||
- clang-3.6
|
||||
- toolset: clang
|
||||
compiler: clang++-3.7
|
||||
cxxstd: "03,11,14"
|
||||
@@ -334,15 +320,26 @@ jobs:
|
||||
linkflags: -stdlib=libc++
|
||||
- toolset: clang
|
||||
compiler: clang++-20
|
||||
cxxstd: "03,11,14,17,20,2b,2c"
|
||||
cxxstd: "03,11,14,17,20,23,2c"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:25.04
|
||||
container: ubuntu:24.04
|
||||
install:
|
||||
- clang-20
|
||||
- libc++-20-dev
|
||||
- libc++abi-20-dev
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- toolset: clang
|
||||
compiler: clang++-21
|
||||
cxxstd: "03,11,14,17,20,23,2c"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:25.10
|
||||
install:
|
||||
- clang-21
|
||||
- libc++-21-dev
|
||||
- libc++abi-21-dev
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- name: UBSAN
|
||||
toolset: clang
|
||||
compiler: clang++-15
|
||||
@@ -365,14 +362,14 @@ jobs:
|
||||
- g++-13
|
||||
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-13
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-14
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
- toolset: clang
|
||||
os: macos-15
|
||||
cxxstd: "03,11,14,17,20,23,2c"
|
||||
- toolset: clang
|
||||
os: macos-26
|
||||
cxxstd: "03,11,14,17,20,23,2c"
|
||||
|
||||
timeout-minutes: 45
|
||||
runs-on: ${{matrix.os}}
|
||||
@@ -680,9 +677,9 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
- os: macos-26
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 10
|
||||
@@ -747,9 +744,9 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
- os: macos-26
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 10
|
||||
@@ -824,9 +821,9 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
- os: macos-26
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 20
|
||||
|
||||
+3
-5
@@ -27,17 +27,15 @@ environment:
|
||||
ADDRMD: 32,64
|
||||
CXXSTD: 14,17
|
||||
|
||||
# clang-win 32 bit fails to link with "unable to load mspdbcore.dll (error code: 126)"
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: clang-win
|
||||
ADDRMD: 64
|
||||
CXXSTD: 14,17,latest
|
||||
CXXSTD: 14,17
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: clang-win
|
||||
ADDRMD: 64
|
||||
CXXSTD: 14,17,latest
|
||||
CXXSTD: 20,latest
|
||||
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# Copyright 2020, 2025 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
project : default-build release <link>static <cxxstd>17
|
||||
: requirements <library>/boost/core//boost_core ;
|
||||
|
||||
exe sv_find_first_of : sv_find_first_of.cpp ;
|
||||
exe sv_find_first_not_of : sv_find_first_not_of.cpp ;
|
||||
@@ -0,0 +1,277 @@
|
||||
// Copyright 2021, 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/utility/string_view.hpp>
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/type_name.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <string_view>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
template<class Sv> void test()
|
||||
{
|
||||
constexpr char const* q1 = "{";
|
||||
constexpr char const* q2 = "<(";
|
||||
constexpr char const* q3 = " :=";
|
||||
constexpr char const* q4 = " \t\r\n";
|
||||
constexpr char const* q6 = " \t\r\n\f\v";
|
||||
constexpr char const* q10 = "0123456789";
|
||||
constexpr char const* q52 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
constexpr std::size_t npos = static_cast<std::size_t>( -1 );
|
||||
|
||||
constexpr std::size_t N = 1'000'000'000;
|
||||
|
||||
std::cout << boost::core::type_name<Sv>() << ":\n\n";
|
||||
|
||||
auto t0 = std::chrono::steady_clock::now();
|
||||
|
||||
{
|
||||
constexpr char const* q = q1;
|
||||
|
||||
std::string s1( 1'000'000, q[ std::strlen( q ) - 1 ] );
|
||||
std::string s2( 100, q[ std::strlen( q ) - 1 ] );
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q2;
|
||||
|
||||
std::string s1( 1'000'000, q[ std::strlen( q ) - 1 ] );
|
||||
std::string s2( 100, q[ std::strlen( q ) - 1 ] );
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q3;
|
||||
|
||||
std::string s1( 1'000'000, q[ std::strlen( q ) - 1 ] );
|
||||
std::string s2( 100, q[ std::strlen( q ) - 1 ] );
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q4;
|
||||
|
||||
std::string s1( 1'000'000, q[ std::strlen( q ) - 1 ] );
|
||||
std::string s2( 100, q[ std::strlen( q ) - 1 ] );
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q6;
|
||||
|
||||
std::string s1( 1'000'000, q[ std::strlen( q ) - 1 ] );
|
||||
std::string s2( 100, q[ std::strlen( q ) - 1 ] );
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q10;
|
||||
|
||||
std::string s1( 1'000'000, q[ std::strlen( q ) - 1 ] );
|
||||
std::string s2( 100, q[ std::strlen( q ) - 1 ] );
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q52;
|
||||
|
||||
std::string s1( 1'000'000, q[ std::strlen( q ) - 1 ] );
|
||||
std::string s2( 100, q[ std::strlen( q ) - 1 ] );
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_not_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_not_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
auto tn = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "\nTotal for " << boost::core::type_name<Sv>() << ": " << ( tn - t0 ) / 1ms << " ms\n\n";
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<std::string_view>();
|
||||
test<boost::string_view>();
|
||||
test<boost::core::string_view>();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
// Copyright 2021, 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/utility/string_view.hpp>
|
||||
#include <boost/core/detail/string_view.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/type_name.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <string_view>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
template<class Sv> void test()
|
||||
{
|
||||
std::string s1( 1'000'000, '\x00' );
|
||||
std::string s2( 100, '\x00' );
|
||||
|
||||
constexpr char const* q1 = "{";
|
||||
constexpr char const* q2 = "<(";
|
||||
constexpr char const* q3 = " :=";
|
||||
constexpr char const* q4 = " \t\r\n";
|
||||
constexpr char const* q6 = " \t\r\n\f\v";
|
||||
constexpr char const* q10 = "0123456789";
|
||||
constexpr char const* q52 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
constexpr std::size_t npos = static_cast<std::size_t>( -1 );
|
||||
|
||||
constexpr std::size_t N = 1'000'000'000;
|
||||
|
||||
std::cout << boost::core::type_name<Sv>() << ":\n\n";
|
||||
|
||||
auto t0 = std::chrono::steady_clock::now();
|
||||
|
||||
{
|
||||
constexpr char const* q = q1;
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q2;
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q3;
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q4;
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q6;
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q10;
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
constexpr char const* q = q52;
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s1.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s1 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s1.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
|
||||
{
|
||||
auto t1 = std::chrono::steady_clock::now();
|
||||
|
||||
for( std::size_t i = 0; i < N / s2.size(); ++i )
|
||||
{
|
||||
BOOST_TEST_EQ( Sv( s2 ).find_first_of( q ), npos );
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "find_first_of( sv, \"" << q << "\" ) in " << s2.size() << " bytes: " << ( t2 - t1 ) / 1ms << " ms\n";
|
||||
}
|
||||
}
|
||||
|
||||
auto tn = std::chrono::steady_clock::now();
|
||||
|
||||
std::cout << "\nTotal for " << boost::core::type_name<Sv>() << ": " << ( tn - t0 ) / 1ms << " ms\n\n";
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<std::string_view>();
|
||||
test<boost::string_view>();
|
||||
test<boost::core::string_view>();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
The header `<boost/core/null_deleter.hpp>` defines the `boost::null_deleter` function object,
|
||||
which can be used as a deleter with smart pointers such as `unique_ptr` or `shared_ptr`. The
|
||||
deleter doesn't do anything with the pointer provided upon deallocation, which makes it useful
|
||||
when the pointed object is deallocated elsewhere.
|
||||
when the pointed object doesn't need to be deallocated or is deallocated elsewhere.
|
||||
|
||||
[section Example]
|
||||
``
|
||||
|
||||
@@ -23,9 +23,15 @@ class span;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class U, class T>
|
||||
template<class U, class T, class = void>
|
||||
struct span_convertible {
|
||||
static constexpr bool value = std::is_convertible<U(*)[], T(*)[]>::value;
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template<class U, class T>
|
||||
struct span_convertible<U, T, typename
|
||||
std::enable_if<std::is_convertible<U(*)[], T(*)[]>::value>::type> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template<std::size_t E, std::size_t N>
|
||||
|
||||
@@ -25,6 +25,20 @@ struct range {
|
||||
}
|
||||
};
|
||||
|
||||
struct buffer {
|
||||
void* data() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const void* data() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::size_t size() const {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct base { };
|
||||
|
||||
struct derived
|
||||
@@ -138,6 +152,10 @@ void test_range()
|
||||
const range<int>&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<base>,
|
||||
range<derived>&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
buffer>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
|
||||
const buffer&>));
|
||||
}
|
||||
|
||||
void test_initializer_list()
|
||||
|
||||
Reference in New Issue
Block a user