mirror of
https://github.com/boostorg/lexical_cast.git
synced 2026-07-23 13:43:54 +00:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 35d8af6ce2 | |||
| 4b0d10a1f3 | |||
| 184f7e43f0 | |||
| 4cc0fa77b4 | |||
| 4d1e18cf4c | |||
| d57771ecf1 | |||
| 1b804c7a31 | |||
| 275844e651 | |||
| 1084d98719 | |||
| 7f60da84c3 | |||
| 8fc8a19931 | |||
| 4862e296d0 | |||
| a16040a73c | |||
| 46ee1c3528 | |||
| 5326b49475 | |||
| 1c89e3a56c | |||
| 71a184d20f | |||
| 7f121f8ce3 | |||
| ff2f0496b0 | |||
| 7861401ac4 | |||
| 92e55e842e | |||
| 02e5821ab3 | |||
| 3433c34b43 | |||
| 518e28ff79 | |||
| fc5ffb67f8 | |||
| 31e0fcde67 | |||
| f0862bb60d | |||
| 4bf37fb6ce | |||
| 621b9cf431 | |||
| 92ef7fdeaf | |||
| fe9ee41f5c | |||
| 90ec909dcf | |||
| a713e09eab |
@@ -0,0 +1,11 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
+110
-19
@@ -17,6 +17,10 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-14 # Do not remove! It is the only toolset that tests CMake tests down below
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-24.04
|
||||
compiler: g++-14
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
@@ -24,24 +28,26 @@ jobs:
|
||||
linkflags: "linkflags=--coverage -lasan -lubsan"
|
||||
gcov_tool: "gcov-12"
|
||||
launcher: "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.8"
|
||||
- toolset: gcc-9
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
cxxflags: "cxxflags=-fsanitize=address,undefined,integer -fno-sanitize-recover=undefined"
|
||||
linkflags: "linkflags=-fsanitize=address,undefined,integer"
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20"
|
||||
os: macos-latest
|
||||
- toolset: clang-19
|
||||
cxxstd: "20,23"
|
||||
os: ubuntu-24.04
|
||||
compiler: clang++-19
|
||||
install: clang-19 llvm-19 libclang-rt-19-dev libc++-19-dev libc++abi-19-dev clang-tools-19
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
@@ -69,8 +75,52 @@ jobs:
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--depth 10 --jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
./b2 -j4 variant=debug tools/inspect/build
|
||||
./b2 -j4 variant=debug tools/inspect
|
||||
|
||||
- name: Run modules tests without 'import std;'
|
||||
if: ${{matrix.toolset == 'clang-19'}}
|
||||
run: |
|
||||
cd ../boost-root/libs/lexical_cast
|
||||
cmake -S test/cmake_subdir_test -B build_module \
|
||||
-GNinja \
|
||||
-DBUILD_TESTING=1 \
|
||||
-DBOOST_USE_MODULES=1 \
|
||||
-DCMAKE_CXX_COMPILER=clang++-19 \
|
||||
-DCMAKE_C_COMPILER=clang-19
|
||||
cmake --build build_module
|
||||
ctest --test-dir build_module -V --no-tests=error
|
||||
rm -rf build_module
|
||||
|
||||
- name: Run modules tests
|
||||
if: ${{matrix.toolset == 'clang-19'}}
|
||||
run: |
|
||||
cd ../boost-root/libs/lexical_cast
|
||||
cmake -S test/cmake_subdir_test -B build_module \
|
||||
-GNinja \
|
||||
-DBUILD_TESTING=1 \
|
||||
-DBOOST_USE_MODULES=1 \
|
||||
-DCMAKE_CXX_COMPILER=clang++-19 \
|
||||
-DCMAKE_C_COMPILER=clang-19 \
|
||||
-DCMAKE_CXX_FLAGS=-stdlib=libc++ \
|
||||
-DCMAKE_CXX_STANDARD=23 \
|
||||
-DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 \
|
||||
-DCMAKE_CXX_MODULE_STD=ON
|
||||
cmake --build build_module
|
||||
ctest --test-dir build_module -V --no-tests=error
|
||||
rm -rf build_module
|
||||
|
||||
- name: Run CMake tests
|
||||
if: ${{matrix.toolset == 'gcc-14' || matrix.toolset == 'clang-19'}}
|
||||
run: |
|
||||
cd ../boost-root/
|
||||
cmake -S . -B __build \
|
||||
-DBUILD_TESTING=1 \
|
||||
-DBOOST_INCLUDE_LIBRARIES=lexical_cast \
|
||||
-DCMAKE_CXX_COMPILER=${{matrix.compiler}} \
|
||||
-DCMAKE_C_COMPILER=${{matrix.toolset}}
|
||||
cmake --build __build --target tests
|
||||
ctest --test-dir __build --output-on-failure --no-tests=error
|
||||
rm -rf __build
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
@@ -111,23 +161,23 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc
|
||||
cxxstd: "14,17,latest"
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: msvc-14.2
|
||||
- toolset: msvc
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
addrmd: 64
|
||||
os: windows-2025
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
@@ -146,10 +196,51 @@ jobs:
|
||||
git clone -b %BOOST_BRANCH% --depth 10 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
|
||||
git submodule update --init tools/boostdep libs/test
|
||||
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--jobs 3" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run CMake tests
|
||||
if: ${{matrix.toolset == 'msvc-14.3'}}
|
||||
shell: cmd
|
||||
run: |
|
||||
choco install --no-progress ninja
|
||||
call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64
|
||||
cd ../boost-root/
|
||||
mkdir __build
|
||||
cd __build
|
||||
cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=lexical_cast -G Ninja ..
|
||||
cmake --build . --target tests --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Run modules tests
|
||||
if: false
|
||||
#if: ${{matrix.toolset == 'msvc-14.3'}}
|
||||
shell: cmd
|
||||
run: |
|
||||
choco install --no-progress ninja
|
||||
call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64
|
||||
cd ../boost-root/libs/lexical_cast
|
||||
rm -rf build_module
|
||||
mkdir build_module
|
||||
cd build_module
|
||||
cmake -DBOOST_USE_MODULES=1 -DCMAKE_CXX_STANDARD=23 -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 -G Ninja ../test/cmake_subdir_test/
|
||||
cmake --build .
|
||||
ctest --no-tests=error -V
|
||||
|
||||
- name: Run modules tests without 'import std;'
|
||||
if: ${{matrix.toolset == 'msvc-14.3'}}
|
||||
shell: cmd
|
||||
run: |
|
||||
choco install --no-progress ninja
|
||||
call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64
|
||||
cd ../boost-root/libs/lexical_cast
|
||||
rm -rf build_module
|
||||
mkdir build_module
|
||||
cd build_module
|
||||
cmake -DBOOST_USE_MODULES=1 -DCMAKE_CXX_STANDARD=20 -G Ninja ../test/cmake_subdir_test/
|
||||
cmake --build .
|
||||
ctest --no-tests=error -V
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
|
||||
+25
-10
@@ -3,29 +3,44 @@
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
cmake_minimum_required(VERSION 3.5...4.0)
|
||||
|
||||
project(boost_lexical_cast VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_lexical_cast INTERFACE)
|
||||
add_library(Boost::lexical_cast ALIAS boost_lexical_cast)
|
||||
|
||||
target_include_directories(boost_lexical_cast INTERFACE include)
|
||||
if (BOOST_USE_MODULES)
|
||||
add_library(boost_lexical_cast)
|
||||
target_sources(boost_lexical_cast PUBLIC
|
||||
FILE_SET modules_public TYPE CXX_MODULES FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/modules/boost_lexical_cast.cppm
|
||||
)
|
||||
|
||||
target_compile_features(boost_lexical_cast PUBLIC cxx_std_20)
|
||||
target_compile_definitions(boost_lexical_cast PUBLIC BOOST_USE_MODULES)
|
||||
if (CMAKE_CXX_COMPILER_IMPORT_STD)
|
||||
target_compile_definitions(boost_lexical_cast PRIVATE BOOST_LEXICAL_CAST_USE_STD_MODULE)
|
||||
message(STATUS "Using `import std;`")
|
||||
else()
|
||||
message(STATUS "`import std;` is not available")
|
||||
endif()
|
||||
set(__scope PUBLIC)
|
||||
else()
|
||||
add_library(boost_lexical_cast INTERFACE)
|
||||
set(__scope INTERFACE)
|
||||
endif()
|
||||
|
||||
target_include_directories(boost_lexical_cast ${__scope} include)
|
||||
target_link_libraries(boost_lexical_cast
|
||||
INTERFACE
|
||||
${__scope}
|
||||
Boost::config
|
||||
Boost::container
|
||||
Boost::core
|
||||
Boost::integer
|
||||
Boost::numeric_conversion
|
||||
Boost::throw_exception
|
||||
Boost::type_traits
|
||||
)
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
add_library(Boost::lexical_cast ALIAS boost_lexical_cast)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# Copyright René Ferdinand Rivera Morell 2023-2024
|
||||
# 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)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/config//boost_config
|
||||
/boost/container//boost_container
|
||||
/boost/core//boost_core
|
||||
/boost/throw_exception//boost_throw_exception ;
|
||||
|
||||
project /boost/lexical_cast
|
||||
: common-requirements
|
||||
<include>include
|
||||
;
|
||||
|
||||
explicit
|
||||
[ alias boost_lexical_cast : : : : <library>$(boost_dependencies) ]
|
||||
[ alias all : boost_lexical_cast test ]
|
||||
;
|
||||
|
||||
call-if : boost-library lexical_cast
|
||||
;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Copyright Antony Polukhin, 2011-2023.
|
||||
# Copyright Antony Polukhin, 2011-2026.
|
||||
#
|
||||
# Use, modification, and distribution are
|
||||
# subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
|
||||
+481
-374
@@ -3,7 +3,7 @@
|
||||
[version 1.0]
|
||||
[copyright 2000-2005 Kevlin Henney]
|
||||
[copyright 2006-2010 Alexander Nasonov]
|
||||
[copyright 2011-2023 Antony Polukhin]
|
||||
[copyright 2011-2026 Antony Polukhin]
|
||||
[category String and text processing]
|
||||
[category Miscellaneous]
|
||||
[license
|
||||
@@ -203,7 +203,7 @@ Read a good C++ book, study `std::sentry` and [@boost:libs/io/doc/ios_state.html
|
||||
[pre
|
||||
]
|
||||
|
||||
* [*Question:] Why `std::cout << boost::lexical_cast<unsigned int>("-1");` does not throw, but outputs 4294967295?
|
||||
* [*Question:] Why does `std::cout << boost::lexical_cast<unsigned int>("-1");` not throw, but outputs 4294967295?
|
||||
* [*Answer:] `boost::lexical_cast` has the behavior of `std::stringstream`, which uses `num_get` functions of
|
||||
`std::locale` to convert numbers. If we look at the Programming languages — C++, we'll see, that `num_get` uses
|
||||
the rules of `scanf` for conversions. And in the C99 standard for unsigned input value minus sign is optional, so
|
||||
@@ -212,7 +212,7 @@ if a negative number is read, no errors will arise and the result will be the tw
|
||||
[pre
|
||||
]
|
||||
|
||||
* [*Question:] Why `boost::lexical_cast<int>(L'A');` outputs 65 and `boost::lexical_cast<wchar_t>(L"65");` does not throw?
|
||||
* [*Question:] Why does `boost::lexical_cast<int>(L'A');` output 65 and `boost::lexical_cast<wchar_t>(L"65");` not throw?
|
||||
* [*Answer:] If you are using an old version of Visual Studio or compile code with /Zc:wchar_t- flag,
|
||||
`boost::lexical_cast` sees single `wchar_t` character as `unsigned short`. It is not a `boost::lexical_cast` mistake, but a
|
||||
limitation of compiler options that you use.
|
||||
@@ -220,7 +220,7 @@ limitation of compiler options that you use.
|
||||
[pre
|
||||
]
|
||||
|
||||
* [*Question:] Why `boost::lexical_cast<double>("-1.#IND");` throws `boost::bad_lexical_cast`?
|
||||
* [*Question:] Why does `boost::lexical_cast<double>("-1.#IND");` throw `boost::bad_lexical_cast`?
|
||||
* [*Answer:] `"-1.#IND"` is a compiler extension, that violates standard. You shall input `"-nan"`, `"nan"`, `"inf"`
|
||||
, `"-inf"` (case insensitive) strings to get NaN and Inf values. `boost::lexical_cast<string>` outputs `"-nan"`, `"nan"`,
|
||||
`"inf"`, `"-inf"` strings, when has NaN or Inf input values.
|
||||
@@ -229,12 +229,66 @@ limitation of compiler options that you use.
|
||||
]
|
||||
|
||||
* [*Question:] What is the fastest way to convert a non zero terminated string or a substring using `boost::lexical_cast`?
|
||||
* [*Answer:] Use `boost::iterator_range` for conversion or `lexical_cast` overload with two parameters. For example, if you whant to convert to `int` two characters from a string `str`, you shall write `lexical_cast<int>(make_iterator_range(str.data(), str.data() + 2));` or `lexical_cast<int>(str.data(), 2);`.
|
||||
* [*Answer:] Use `boost::iterator_range` for conversion or `lexical_cast` overload with two parameters. For example, if you want to convert to `int` two characters from a string `str`, you shall write `lexical_cast<int>(make_iterator_range(str.data(), str.data() + 2));` or `lexical_cast<int>(str.data(), 2);`.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section C++20 module]
|
||||
|
||||
[caution C++20 module support is on early stage, targets, flags and behavior may change in the future]
|
||||
|
||||
If using modern CMake define CMake option `-DBOOST_USE_MODULES=1` to build a C++20 module and
|
||||
make the `Boost::lexical_cast` CMake target provide it. After that an explicit usage of C++20 module `boost.lexical_cast` is allowed:
|
||||
|
||||
[import ../modules/usage_sample.cpp]
|
||||
[lexical_cast_module_example]
|
||||
|
||||
The `Boost::lexical_cast` CMake target gives an ability to mix includes and imports of the library in different translation units. Moreover,
|
||||
if `BOOST_USE_MODULES` macro is defined then all the `boost/lexical_cast...` includes implicitly do `import boost.lexical_cast;` to give all the
|
||||
benefits of modules without changing the existing code.
|
||||
|
||||
[note For better compile times make sure that `import std;` is available when building the `boost.lexical_cast` module (in CMake logs there should be
|
||||
a 'Using `import std;`' message). ]
|
||||
|
||||
If not using CMake, then the module could be build manually from the `modules/boost_lexical_cast.cppm` file.
|
||||
|
||||
For manual module build the following commands could be used for clang compiler:
|
||||
|
||||
```
|
||||
cd lexical_cast/modules
|
||||
clang++ -I ../include -std=c++20 --precompile -x c++-module boost_lexical_cast.cppm
|
||||
```
|
||||
|
||||
After that, the module could be used in the following way:
|
||||
|
||||
```
|
||||
clang++ -std=c++20 -fmodule-file=boost_lexical_cast.pcm boost_lexical_cast.pcm usage_sample.cpp
|
||||
```
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Changes]
|
||||
|
||||
* [*boost 1.91.0 :]
|
||||
* Added C++20 modules support.
|
||||
|
||||
* [*boost 1.86.0 :]
|
||||
|
||||
* Fixed conversion of `std::basic_string_view` and `boost::basic_string_view`
|
||||
containing one or more `\0` characters. Issue was introduced in 1.85.0.
|
||||
|
||||
* [*boost 1.85.0 :]
|
||||
|
||||
* Significant rewrite of the internal logic to separate optimized and C++ Standard Library IO-based streams:
|
||||
* C++ Standard Library based streams now constructed in less cases leading to [*better performance];
|
||||
* less template instantiations and simpler code;
|
||||
* always use `std::char_traits` (do not use custom traits from input/output types as it leads to linktime or runtime errors);
|
||||
* support for `volatile` input types was dropped, following the C++ Standard Library trend.
|
||||
* Optimized conversions from std::basic_string_view and boost::basic_string_view
|
||||
* Dropped dependency on Boost.NumericConversion and Boost.MPL. Fixed some cases
|
||||
of converting floting point types to arithmetics.
|
||||
* The library now works fine with `-fno-sanitize-recover=integer`.
|
||||
|
||||
* [*boost 1.84.0 :]
|
||||
|
||||
* Dropped support of C++98 and C++03.
|
||||
@@ -358,380 +412,433 @@ Do not use this results to compare compilers, because tests were taken on differ
|
||||
[/ BEGIN of section, generated by performance measuring program ]
|
||||
|
||||
|
||||
[section GNU C++ version 6.1.1 20160511]
|
||||
[table:id Performance Table ( GNU C++ version 6.1.1 20160511)
|
||||
|
||||
[section GNU C++ version 9.4.0]
|
||||
[table:id Performance Table ( GNU C++ version 9.4.0)
|
||||
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
|
||||
[[ string->char ][ !!! *<1* !!! ][ 59 ][ 4 ][ 4 ]]
|
||||
[[ string->signed char ][ !!! *<1* !!! ][ 52 ][ 4 ][ 5 ]]
|
||||
[[ string->unsigned char ][ !!! *<1* !!! ][ 54 ][ 4 ][ 5 ]]
|
||||
[[ string->int ][ !!! *4* !!! ][ 61 ][ 19 ][ 12 ]]
|
||||
[[ string->short ][ !!! *4* !!! ][ 59 ][ 11 ][ 8 ]]
|
||||
[[ string->long int ][ !!! *4* !!! ][ 59 ][ 9 ][ 8 ]]
|
||||
[[ string->long long ][ !!! *6* !!! ][ 61 ][ 10 ][ 10 ]]
|
||||
[[ string->unsigned int ][ !!! *4* !!! ][ 59 ][ 9 ][ 9 ]]
|
||||
[[ string->unsigned short ][ !!! *4* !!! ][ 60 ][ 9 ][ 8 ]]
|
||||
[[ string->unsigned long int ][ !!! *4* !!! ][ 60 ][ 9 ][ 8 ]]
|
||||
[[ string->unsigned long long ][ !!! *4* !!! ][ 70 ][ 21 ][ 21 ]]
|
||||
[[ string->float ][ 91 ][ 152 ][ 59 ][ !!! *40* !!! ]]
|
||||
[[ string->double ][ 86 ][ 140 ][ 58 ][ !!! *28* !!! ]]
|
||||
[[ string->long double ][ 48 ][ 90 ][ 34 ][ !!! *22* !!! ]]
|
||||
[[ string->array<char, 50> ][ !!! *<1* !!! ][ 59 ][ 9 ][ 10 ]]
|
||||
[[ string->string ][ !!! *2* !!! ][ 129 ][ 29 ][ --- ]]
|
||||
[[ string->container::string ][ !!! *1* !!! ][ 70 ][ 11 ][ --- ]]
|
||||
[[ string->char ][ !!! *4* !!! ][ 99 ][ 27 ][ 20 ]]
|
||||
[[ string->signed char ][ !!! *9* !!! ][ 101 ][ 13 ][ 12 ]]
|
||||
[[ string->unsigned char ][ !!! *4* !!! ][ 86 ][ 27 ][ 27 ]]
|
||||
[[ int->string ][ !!! *9* !!! ][ 89 ][ 17 ][ 14 ]]
|
||||
[[ short->string ][ !!! *7* !!! ][ 71 ][ 17 ][ 15 ]]
|
||||
[[ long int->string ][ !!! *7* !!! ][ 71 ][ 18 ][ 19 ]]
|
||||
[[ long long->string ][ !!! *13* !!! ][ 127 ][ 34 ][ 25 ]]
|
||||
[[ unsigned int->string ][ 16 ][ 117 ][ 17 ][ !!! *12* !!! ]]
|
||||
[[ unsigned short->string ][ !!! *8* !!! ][ 71 ][ 16 ][ 12 ]]
|
||||
[[ unsigned long int->string ][ !!! *12* !!! ][ 100 ][ 36 ][ 26 ]]
|
||||
[[ unsigned long long->string ][ !!! *14* !!! ][ 97 ][ 21 ][ 17 ]]
|
||||
[[ float->string ][ 70 ][ 97 ][ 43 ][ !!! *25* !!! ]]
|
||||
[[ double->string ][ 130 ][ 155 ][ 51 ][ !!! *25* !!! ]]
|
||||
[[ long double->string ][ 104 ][ 160 ][ !!! *47* !!! ][ 57 ]]
|
||||
[[ char*->char ][ !!! *<1* !!! ][ 95 ][ 4 ][ 4 ]]
|
||||
[[ char*->signed char ][ !!! *<1* !!! ][ 52 ][ 7 ][ 13 ]]
|
||||
[[ char*->unsigned char ][ !!! *<1* !!! ][ 106 ][ 11 ][ 13 ]]
|
||||
[[ char*->int ][ !!! *6* !!! ][ 118 ][ 22 ][ 21 ]]
|
||||
[[ char*->short ][ !!! *7* !!! ][ 104 ][ 10 ][ 19 ]]
|
||||
[[ char*->long int ][ !!! *8* !!! ][ 112 ][ 24 ][ 14 ]]
|
||||
[[ char*->long long ][ !!! *4* !!! ][ 90 ][ 17 ][ 9 ]]
|
||||
[[ char*->unsigned int ][ !!! *4* !!! ][ 103 ][ 23 ][ 22 ]]
|
||||
[[ char*->unsigned short ][ !!! *7* !!! ][ 82 ][ 9 ][ 8 ]]
|
||||
[[ char*->unsigned long int ][ !!! *5* !!! ][ 58 ][ 20 ][ 8 ]]
|
||||
[[ char*->unsigned long long ][ !!! *4* !!! ][ 60 ][ 10 ][ 11 ]]
|
||||
[[ char*->float ][ 58 ][ 103 ][ !!! *32* !!! ][ 37 ]]
|
||||
[[ char*->double ][ 52 ][ 155 ][ 32 ][ !!! *27* !!! ]]
|
||||
[[ char*->long double ][ 72 ][ 135 ][ 51 ][ !!! *30* !!! ]]
|
||||
[[ char*->array<char, 50> ][ !!! *<1* !!! ][ 80 ][ 23 ][ 17 ]]
|
||||
[[ char*->string ][ !!! *10* !!! ][ 150 ][ 18 ][ --- ]]
|
||||
[[ string->char ][ !!! *<1* !!! ][ 59 ][ 7 ][ 17 ]]
|
||||
[[ string->signed char ][ !!! *<1* !!! ][ 142 ][ 13 ][ 21 ]]
|
||||
[[ string->unsigned char ][ !!! *<1* !!! ][ 63 ][ 5 ][ 8 ]]
|
||||
[[ string->int ][ !!! *4* !!! ][ 63 ][ 13 ][ 12 ]]
|
||||
[[ string->short ][ !!! *4* !!! ][ 65 ][ 12 ][ 12 ]]
|
||||
[[ string->long int ][ !!! *4* !!! ][ 62 ][ 12 ][ 12 ]]
|
||||
[[ string->long long ][ !!! *3* !!! ][ 61 ][ 13 ][ 12 ]]
|
||||
[[ string->unsigned int ][ !!! *4* !!! ][ 58 ][ 10 ][ 12 ]]
|
||||
[[ string->unsigned short ][ !!! *4* !!! ][ 59 ][ 10 ][ 12 ]]
|
||||
[[ string->unsigned long int ][ !!! *4* !!! ][ 62 ][ 11 ][ 12 ]]
|
||||
[[ string->unsigned long long ][ !!! *4* !!! ][ 64 ][ 11 ][ 12 ]]
|
||||
[[ string->float ][ 59 ][ 92 ][ 35 ][ !!! *23* !!! ]]
|
||||
[[ string->double ][ 55 ][ 89 ][ 31 ][ !!! *23* !!! ]]
|
||||
[[ string->long double ][ 52 ][ 83 ][ 32 ][ !!! *26* !!! ]]
|
||||
[[ string->array<char, 50> ][ !!! *<1* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ string->string ][ !!! *1* !!! ][ 68 ][ 13 ][ --- ]]
|
||||
[[ string->container::string ][ !!! *<1* !!! ][ 65 ][ 11 ][ --- ]]
|
||||
[[ string->char ][ !!! *1* !!! ][ 58 ][ 10 ][ 7 ]]
|
||||
[[ string->signed char ][ !!! *1* !!! ][ 57 ][ 10 ][ 10 ]]
|
||||
[[ string->unsigned char ][ !!! *1* !!! ][ 57 ][ 10 ][ 10 ]]
|
||||
[[ int->string ][ !!! *4* !!! ][ 64 ][ 13 ][ 10 ]]
|
||||
[[ short->string ][ !!! *4* !!! ][ 69 ][ 13 ][ 10 ]]
|
||||
[[ long int->string ][ !!! *4* !!! ][ 68 ][ 13 ][ 10 ]]
|
||||
[[ long long->string ][ !!! *4* !!! ][ 66 ][ 13 ][ 10 ]]
|
||||
[[ unsigned int->string ][ !!! *4* !!! ][ 62 ][ 14 ][ 10 ]]
|
||||
[[ unsigned short->string ][ !!! *4* !!! ][ 66 ][ 13 ][ 10 ]]
|
||||
[[ unsigned long int->string ][ !!! *4* !!! ][ 70 ][ 13 ][ 10 ]]
|
||||
[[ unsigned long long->string ][ !!! *4* !!! ][ 64 ][ 14 ][ 10 ]]
|
||||
[[ float->string ][ 26 ][ 108 ][ 50 ][ !!! *23* !!! ]]
|
||||
[[ double->string ][ 33 ][ 114 ][ 51 ][ !!! *26* !!! ]]
|
||||
[[ long double->string ][ 88 ][ 194 ][ 54 ][ !!! *26* !!! ]]
|
||||
[[ char*->char ][ !!! *<1* !!! ][ 53 ][ 6 ][ 5 ]]
|
||||
[[ char*->signed char ][ !!! *<1* !!! ][ 52 ][ 6 ][ 7 ]]
|
||||
[[ char*->unsigned char ][ !!! *<1* !!! ][ 55 ][ 6 ][ 7 ]]
|
||||
[[ char*->int ][ !!! *4* !!! ][ 67 ][ 12 ][ 10 ]]
|
||||
[[ char*->short ][ !!! *4* !!! ][ 68 ][ 13 ][ 10 ]]
|
||||
[[ char*->long int ][ !!! *3* !!! ][ 68 ][ 13 ][ 10 ]]
|
||||
[[ char*->long long ][ !!! *3* !!! ][ 67 ][ 14 ][ 10 ]]
|
||||
[[ char*->unsigned int ][ !!! *3* !!! ][ 67 ][ 11 ][ 10 ]]
|
||||
[[ char*->unsigned short ][ !!! *3* !!! ][ 61 ][ 11 ][ 11 ]]
|
||||
[[ char*->unsigned long int ][ !!! *3* !!! ][ 61 ][ 13 ][ 10 ]]
|
||||
[[ char*->unsigned long long ][ !!! *3* !!! ][ 67 ][ 13 ][ 10 ]]
|
||||
[[ char*->float ][ 56 ][ 93 ][ 35 ][ !!! *21* !!! ]]
|
||||
[[ char*->double ][ 59 ][ 88 ][ 33 ][ !!! *21* !!! ]]
|
||||
[[ char*->long double ][ 54 ][ 88 ][ 33 ][ !!! *24* !!! ]]
|
||||
[[ char*->array<char, 50> ][ !!! *<1* !!! ][ 63 ][ 11 ][ 8 ]]
|
||||
[[ char*->string ][ !!! *1* !!! ][ 65 ][ 12 ][ --- ]]
|
||||
[[ char*->container::string ][ !!! *<1* !!! ][ 71 ][ 13 ][ --- ]]
|
||||
[[ unsigned char*->char ][ !!! *<1* !!! ][ 57 ][ 6 ][ 5 ]]
|
||||
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 57 ][ 6 ][ 7 ]]
|
||||
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 63 ][ 5 ][ 6 ]]
|
||||
[[ unsigned char*->int ][ !!! *4* !!! ][ 63 ][ 12 ][ 10 ]]
|
||||
[[ unsigned char*->short ][ !!! *4* !!! ][ 65 ][ 13 ][ 10 ]]
|
||||
[[ unsigned char*->long int ][ !!! *3* !!! ][ 67 ][ 12 ][ 10 ]]
|
||||
[[ unsigned char*->long long ][ !!! *3* !!! ][ 66 ][ 12 ][ 10 ]]
|
||||
[[ unsigned char*->unsigned int ][ !!! *3* !!! ][ 64 ][ 11 ][ 10 ]]
|
||||
[[ unsigned char*->unsigned short ][ !!! *3* !!! ][ 65 ][ 12 ][ 10 ]]
|
||||
[[ unsigned char*->unsigned long int ][ !!! *3* !!! ][ 60 ][ 13 ][ 10 ]]
|
||||
[[ unsigned char*->unsigned long long ][ !!! *3* !!! ][ 62 ][ 12 ][ 10 ]]
|
||||
[[ unsigned char*->float ][ 57 ][ 94 ][ 34 ][ !!! *21* !!! ]]
|
||||
[[ unsigned char*->double ][ 60 ][ 88 ][ 35 ][ !!! *21* !!! ]]
|
||||
[[ unsigned char*->long double ][ 54 ][ 89 ][ 32 ][ !!! *24* !!! ]]
|
||||
[[ unsigned char*->array<char, 50> ][ !!! *<1* !!! ][ 68 ][ 12 ][ 8 ]]
|
||||
[[ unsigned char*->string ][ !!! *1* !!! ][ 61 ][ 13 ][ --- ]]
|
||||
[[ unsigned char*->container::string ][ !!! *<1* !!! ][ 66 ][ 12 ][ --- ]]
|
||||
[[ signed char*->char ][ !!! *<1* !!! ][ 58 ][ 6 ][ 5 ]]
|
||||
[[ signed char*->signed char ][ !!! *<1* !!! ][ 59 ][ 6 ][ 7 ]]
|
||||
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 57 ][ 6 ][ 7 ]]
|
||||
[[ signed char*->int ][ !!! *4* !!! ][ 68 ][ 12 ][ 10 ]]
|
||||
[[ signed char*->short ][ !!! *4* !!! ][ 68 ][ 12 ][ 10 ]]
|
||||
[[ signed char*->long int ][ !!! *3* !!! ][ 69 ][ 12 ][ 10 ]]
|
||||
[[ signed char*->long long ][ !!! *3* !!! ][ 61 ][ 12 ][ 11 ]]
|
||||
[[ signed char*->unsigned int ][ !!! *3* !!! ][ 59 ][ 11 ][ 10 ]]
|
||||
[[ signed char*->unsigned short ][ !!! *3* !!! ][ 58 ][ 11 ][ 10 ]]
|
||||
[[ signed char*->unsigned long int ][ !!! *3* !!! ][ 59 ][ 12 ][ 10 ]]
|
||||
[[ signed char*->unsigned long long ][ !!! *3* !!! ][ 68 ][ 12 ][ 10 ]]
|
||||
[[ signed char*->float ][ 55 ][ 93 ][ 39 ][ !!! *22* !!! ]]
|
||||
[[ signed char*->double ][ 56 ][ 95 ][ 34 ][ !!! *23* !!! ]]
|
||||
[[ signed char*->long double ][ 58 ][ 89 ][ 32 ][ !!! *23* !!! ]]
|
||||
[[ signed char*->array<char, 50> ][ !!! *<1* !!! ][ 70 ][ 11 ][ 8 ]]
|
||||
[[ signed char*->string ][ !!! *1* !!! ][ 64 ][ 15 ][ --- ]]
|
||||
[[ signed char*->container::string ][ !!! *1* !!! ][ 67 ][ 13 ][ --- ]]
|
||||
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 62 ][ 6 ][ 7 ]]
|
||||
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 56 ][ 6 ][ 8 ]]
|
||||
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 57 ][ 5 ][ 11 ]]
|
||||
[[ iterator_range<char*>->int ][ !!! *4* !!! ][ 75 ][ 16 ][ 12 ]]
|
||||
[[ iterator_range<char*>->short ][ !!! *3* !!! ][ 69 ][ 16 ][ 12 ]]
|
||||
[[ iterator_range<char*>->long int ][ !!! *3* !!! ][ 66 ][ 21 ][ 12 ]]
|
||||
[[ iterator_range<char*>->long long ][ !!! *3* !!! ][ 70 ][ 15 ][ 12 ]]
|
||||
[[ iterator_range<char*>->unsigned int ][ !!! *3* !!! ][ 67 ][ 16 ][ 12 ]]
|
||||
[[ iterator_range<char*>->unsigned short ][ !!! *3* !!! ][ 64 ][ 14 ][ 12 ]]
|
||||
[[ iterator_range<char*>->unsigned long int ][ !!! *3* !!! ][ 66 ][ 15 ][ 12 ]]
|
||||
[[ iterator_range<char*>->unsigned long long ][ !!! *3* !!! ][ 72 ][ 17 ][ 12 ]]
|
||||
[[ iterator_range<char*>->float ][ 55 ][ 100 ][ 42 ][ !!! *23* !!! ]]
|
||||
[[ iterator_range<char*>->double ][ 54 ][ 100 ][ 40 ][ !!! *23* !!! ]]
|
||||
[[ iterator_range<char*>->long double ][ 56 ][ 100 ][ 39 ][ !!! *25* !!! ]]
|
||||
[[ iterator_range<char*>->array<char, 50> ][ !!! *<1* !!! ][ 69 ][ 20 ][ 10 ]]
|
||||
[[ iterator_range<char*>->string ][ !!! *1* !!! ][ 72 ][ 21 ][ --- ]]
|
||||
[[ iterator_range<char*>->container::string ][ !!! *<1* !!! ][ 82 ][ 21 ][ --- ]]
|
||||
[[ std::string_view->char ][ !!! *<1* !!! ][ 65 ][ 5 ][ 8 ]]
|
||||
[[ std::string_view->signed char ][ !!! *<1* !!! ][ 61 ][ 6 ][ 10 ]]
|
||||
[[ std::string_view->unsigned char ][ !!! *<1* !!! ][ 56 ][ 5 ][ 9 ]]
|
||||
[[ std::string_view->int ][ !!! *4* !!! ][ 59 ][ 12 ][ 14 ]]
|
||||
[[ std::string_view->short ][ !!! *4* !!! ][ 63 ][ 12 ][ 14 ]]
|
||||
[[ std::string_view->long int ][ !!! *4* !!! ][ 61 ][ 11 ][ 13 ]]
|
||||
[[ std::string_view->long long ][ !!! *4* !!! ][ 58 ][ 13 ][ 14 ]]
|
||||
[[ std::string_view->unsigned int ][ !!! *3* !!! ][ 65 ][ 10 ][ 13 ]]
|
||||
[[ std::string_view->unsigned short ][ !!! *3* !!! ][ 64 ][ 10 ][ 14 ]]
|
||||
[[ std::string_view->unsigned long int ][ !!! *3* !!! ][ 64 ][ 12 ][ 13 ]]
|
||||
[[ std::string_view->unsigned long long ][ !!! *3* !!! ][ 65 ][ 11 ][ 14 ]]
|
||||
[[ std::string_view->float ][ 55 ][ 89 ][ 35 ][ !!! *24* !!! ]]
|
||||
[[ std::string_view->double ][ 53 ][ 87 ][ 36 ][ !!! *25* !!! ]]
|
||||
[[ std::string_view->long double ][ 56 ][ 93 ][ 34 ][ !!! *28* !!! ]]
|
||||
[[ std::string_view->array<char, 50> ][ !!! *1* !!! ][ 64 ][ 10 ][ 11 ]]
|
||||
[[ std::string_view->string ][ !!! *1* !!! ][ 62 ][ 11 ][ --- ]]
|
||||
[[ std::string_view->container::string ][ !!! *1* !!! ][ 65 ][ 11 ][ --- ]]
|
||||
[[ array<char, 50>->char ][ !!! *<1* !!! ][ 54 ][ 6 ][ 5 ]]
|
||||
[[ array<char, 50>->signed char ][ !!! *<1* !!! ][ 54 ][ 5 ][ 7 ]]
|
||||
[[ array<char, 50>->unsigned char ][ !!! *<1* !!! ][ 53 ][ 6 ][ 6 ]]
|
||||
[[ array<char, 50>->int ][ !!! *2* !!! ][ 59 ][ 12 ][ 10 ]]
|
||||
[[ array<char, 50>->short ][ !!! *3* !!! ][ 58 ][ 12 ][ 10 ]]
|
||||
[[ array<char, 50>->long int ][ !!! *3* !!! ][ 57 ][ 12 ][ 10 ]]
|
||||
[[ array<char, 50>->long long ][ !!! *3* !!! ][ 60 ][ 12 ][ 10 ]]
|
||||
[[ array<char, 50>->unsigned int ][ !!! *3* !!! ][ 60 ][ 11 ][ 10 ]]
|
||||
[[ array<char, 50>->unsigned short ][ !!! *3* !!! ][ 58 ][ 11 ][ 10 ]]
|
||||
[[ array<char, 50>->unsigned long int ][ !!! *3* !!! ][ 61 ][ 11 ][ 10 ]]
|
||||
[[ array<char, 50>->unsigned long long ][ !!! *3* !!! ][ 59 ][ 12 ][ 10 ]]
|
||||
[[ array<char, 50>->float ][ 52 ][ 89 ][ 35 ][ !!! *21* !!! ]]
|
||||
[[ array<char, 50>->double ][ 50 ][ 91 ][ 33 ][ !!! *21* !!! ]]
|
||||
[[ array<char, 50>->long double ][ 52 ][ 83 ][ 33 ][ !!! *23* !!! ]]
|
||||
[[ array<char, 50>->array<char, 50> ][ !!! *<1* !!! ][ 59 ][ 11 ][ 8 ]]
|
||||
[[ array<char, 50>->string ][ !!! *1* !!! ][ 66 ][ 13 ][ --- ]]
|
||||
[[ array<char, 50>->container::string ][ !!! *1* !!! ][ 61 ][ 12 ][ --- ]]
|
||||
[[ int->int ][ !!! *<1* !!! ][ 61 ][ 14 ][ --- ]]
|
||||
[[ float->double ][ !!! *<1* !!! ][ 136 ][ 72 ][ --- ]]
|
||||
[[ char->signed char ][ !!! *<1* !!! ][ 54 ][ 5 ][ --- ]]
|
||||
]
|
||||
[endsect]
|
||||
|
||||
[section Clang version 15.0.7 ]
|
||||
[table:id Performance Table ( Clang version 15.0.7 )
|
||||
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
|
||||
[[ string->char ][ !!! *<1* !!! ][ 68 ][ 5 ][ 6 ]]
|
||||
[[ string->signed char ][ !!! *<1* !!! ][ 59 ][ 5 ][ 7 ]]
|
||||
[[ string->unsigned char ][ !!! *<1* !!! ][ 59 ][ 5 ][ 7 ]]
|
||||
[[ string->int ][ !!! *3* !!! ][ 69 ][ 11 ][ 10 ]]
|
||||
[[ string->short ][ !!! *3* !!! ][ 64 ][ 11 ][ 10 ]]
|
||||
[[ string->long int ][ !!! *3* !!! ][ 65 ][ 11 ][ 10 ]]
|
||||
[[ string->long long ][ !!! *3* !!! ][ 68 ][ 13 ][ 10 ]]
|
||||
[[ string->unsigned int ][ !!! *3* !!! ][ 65 ][ 10 ][ 10 ]]
|
||||
[[ string->unsigned short ][ !!! *3* !!! ][ 64 ][ 10 ][ 10 ]]
|
||||
[[ string->unsigned long int ][ !!! *3* !!! ][ 62 ][ 11 ][ 10 ]]
|
||||
[[ string->unsigned long long ][ !!! *3* !!! ][ 64 ][ 11 ][ 10 ]]
|
||||
[[ string->float ][ 55 ][ 90 ][ 33 ][ !!! *22* !!! ]]
|
||||
[[ string->double ][ 56 ][ 89 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ string->long double ][ 55 ][ 92 ][ 32 ][ !!! *23* !!! ]]
|
||||
[[ string->array<char, 50> ][ !!! *<1* !!! ][ 66 ][ 10 ][ 8 ]]
|
||||
[[ string->string ][ !!! *1* !!! ][ 66 ][ 12 ][ --- ]]
|
||||
[[ string->container::string ][ !!! *<1* !!! ][ 66 ][ 15 ][ --- ]]
|
||||
[[ string->char ][ !!! *<1* !!! ][ 61 ][ 9 ][ 1 ]]
|
||||
[[ string->signed char ][ !!! *<1* !!! ][ 62 ][ 9 ][ 10 ]]
|
||||
[[ string->unsigned char ][ !!! *<1* !!! ][ 59 ][ 9 ][ 10 ]]
|
||||
[[ int->string ][ !!! *4* !!! ][ 63 ][ 13 ][ 9 ]]
|
||||
[[ short->string ][ !!! *4* !!! ][ 69 ][ 13 ][ 10 ]]
|
||||
[[ long int->string ][ !!! *4* !!! ][ 67 ][ 13 ][ 10 ]]
|
||||
[[ long long->string ][ !!! *4* !!! ][ 65 ][ 13 ][ 10 ]]
|
||||
[[ unsigned int->string ][ !!! *4* !!! ][ 66 ][ 13 ][ 10 ]]
|
||||
[[ unsigned short->string ][ !!! *4* !!! ][ 67 ][ 13 ][ 10 ]]
|
||||
[[ unsigned long int->string ][ !!! *4* !!! ][ 66 ][ 12 ][ 10 ]]
|
||||
[[ unsigned long long->string ][ !!! *4* !!! ][ 67 ][ 13 ][ 10 ]]
|
||||
[[ float->string ][ 25 ][ 108 ][ 47 ][ !!! *22* !!! ]]
|
||||
[[ double->string ][ !!! *32* !!! ][ 130 ][ 116 ][ 56 ]]
|
||||
[[ long double->string ][ 103 ][ 266 ][ 123 ][ !!! *64* !!! ]]
|
||||
[[ char*->char ][ !!! *<1* !!! ][ 129 ][ 13 ][ 14 ]]
|
||||
[[ char*->signed char ][ !!! *<1* !!! ][ 131 ][ 13 ][ 17 ]]
|
||||
[[ char*->unsigned char ][ !!! *<1* !!! ][ 133 ][ 13 ][ 17 ]]
|
||||
[[ char*->int ][ !!! *7* !!! ][ 154 ][ 32 ][ 26 ]]
|
||||
[[ char*->short ][ !!! *7* !!! ][ 161 ][ 29 ][ 27 ]]
|
||||
[[ char*->long int ][ !!! *7* !!! ][ 159 ][ 30 ][ 27 ]]
|
||||
[[ char*->long long ][ !!! *7* !!! ][ 158 ][ 28 ][ 26 ]]
|
||||
[[ char*->unsigned int ][ !!! *7* !!! ][ 146 ][ 26 ][ 26 ]]
|
||||
[[ char*->unsigned short ][ !!! *7* !!! ][ 150 ][ 26 ][ 26 ]]
|
||||
[[ char*->unsigned long int ][ !!! *7* !!! ][ 159 ][ 28 ][ 26 ]]
|
||||
[[ char*->unsigned long long ][ !!! *7* !!! ][ 158 ][ 30 ][ 27 ]]
|
||||
[[ char*->float ][ 123 ][ 207 ][ 78 ][ !!! *54* !!! ]]
|
||||
[[ char*->double ][ 135 ][ 218 ][ 77 ][ !!! *54* !!! ]]
|
||||
[[ char*->long double ][ 130 ][ 216 ][ 82 ][ !!! *59* !!! ]]
|
||||
[[ char*->array<char, 50> ][ !!! *<1* !!! ][ 153 ][ 25 ][ 21 ]]
|
||||
[[ char*->string ][ !!! *2* !!! ][ 159 ][ 31 ][ --- ]]
|
||||
[[ char*->container::string ][ !!! *3* !!! ][ 151 ][ 15 ][ --- ]]
|
||||
[[ unsigned char*->char ][ !!! *<1* !!! ][ 56 ][ 5 ][ 6 ]]
|
||||
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 58 ][ 5 ][ 7 ]]
|
||||
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 59 ][ 5 ][ 7 ]]
|
||||
[[ unsigned char*->int ][ !!! *3* !!! ][ 58 ][ 12 ][ 11 ]]
|
||||
[[ unsigned char*->short ][ !!! *3* !!! ][ 67 ][ 12 ][ 11 ]]
|
||||
[[ unsigned char*->long int ][ !!! *3* !!! ][ 67 ][ 12 ][ 11 ]]
|
||||
[[ unsigned char*->long long ][ !!! *3* !!! ][ 70 ][ 11 ][ 11 ]]
|
||||
[[ unsigned char*->unsigned int ][ !!! *3* !!! ][ 60 ][ 10 ][ 10 ]]
|
||||
[[ unsigned char*->unsigned short ][ !!! *3* !!! ][ 65 ][ 10 ][ 11 ]]
|
||||
[[ unsigned char*->unsigned long int ][ !!! *3* !!! ][ 61 ][ 11 ][ 10 ]]
|
||||
[[ unsigned char*->unsigned long long ][ !!! *3* !!! ][ 58 ][ 11 ][ 10 ]]
|
||||
[[ unsigned char*->float ][ 51 ][ 88 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ unsigned char*->double ][ 54 ][ 88 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ unsigned char*->long double ][ 51 ][ 88 ][ 35 ][ !!! *24* !!! ]]
|
||||
[[ unsigned char*->array<char, 50> ][ !!! *<1* !!! ][ 127 ][ 26 ][ 21 ]]
|
||||
[[ unsigned char*->string ][ !!! *2* !!! ][ 90 ][ 11 ][ --- ]]
|
||||
[[ unsigned char*->container::string ][ !!! *1* !!! ][ 62 ][ 15 ][ --- ]]
|
||||
[[ signed char*->char ][ !!! *<1* !!! ][ 52 ][ 5 ][ 5 ]]
|
||||
[[ signed char*->signed char ][ !!! *<1* !!! ][ 53 ][ 5 ][ 7 ]]
|
||||
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 52 ][ 5 ][ 7 ]]
|
||||
[[ signed char*->int ][ !!! *3* !!! ][ 60 ][ 12 ][ 11 ]]
|
||||
[[ signed char*->short ][ !!! *3* !!! ][ 63 ][ 12 ][ 11 ]]
|
||||
[[ signed char*->long int ][ !!! *3* !!! ][ 63 ][ 11 ][ 11 ]]
|
||||
[[ signed char*->long long ][ !!! *3* !!! ][ 64 ][ 11 ][ 11 ]]
|
||||
[[ signed char*->unsigned int ][ !!! *3* !!! ][ 60 ][ 10 ][ 10 ]]
|
||||
[[ signed char*->unsigned short ][ !!! *3* !!! ][ 59 ][ 10 ][ 10 ]]
|
||||
[[ signed char*->unsigned long int ][ !!! *2* !!! ][ 62 ][ 11 ][ 10 ]]
|
||||
[[ signed char*->unsigned long long ][ !!! *3* !!! ][ 66 ][ 11 ][ 10 ]]
|
||||
[[ signed char*->float ][ 51 ][ 86 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ signed char*->double ][ 55 ][ 87 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ signed char*->long double ][ 55 ][ 86 ][ 32 ][ !!! *24* !!! ]]
|
||||
[[ signed char*->array<char, 50> ][ !!! *<1* !!! ][ 64 ][ 10 ][ 8 ]]
|
||||
[[ signed char*->string ][ !!! *1* !!! ][ 62 ][ 12 ][ --- ]]
|
||||
[[ signed char*->container::string ][ !!! *1* !!! ][ 66 ][ 15 ][ --- ]]
|
||||
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 53 ][ 5 ][ 5 ]]
|
||||
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 55 ][ 5 ][ 7 ]]
|
||||
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 57 ][ 5 ][ 7 ]]
|
||||
[[ iterator_range<char*>->int ][ !!! *3* !!! ][ 67 ][ 15 ][ 11 ]]
|
||||
[[ iterator_range<char*>->short ][ !!! *3* !!! ][ 96 ][ 37 ][ 27 ]]
|
||||
[[ iterator_range<char*>->long int ][ !!! *7* !!! ][ 166 ][ 37 ][ 27 ]]
|
||||
[[ iterator_range<char*>->long long ][ !!! *7* !!! ][ 150 ][ 37 ][ 26 ]]
|
||||
[[ iterator_range<char*>->unsigned int ][ !!! *7* !!! ][ 158 ][ 34 ][ 26 ]]
|
||||
[[ iterator_range<char*>->unsigned short ][ !!! *7* !!! ][ 170 ][ 36 ][ 26 ]]
|
||||
[[ iterator_range<char*>->unsigned long int ][ !!! *7* !!! ][ 154 ][ 35 ][ 26 ]]
|
||||
[[ iterator_range<char*>->unsigned long long ][ !!! *7* !!! ][ 158 ][ 36 ][ 26 ]]
|
||||
[[ iterator_range<char*>->float ][ 122 ][ 233 ][ 100 ][ !!! *54* !!! ]]
|
||||
[[ iterator_range<char*>->double ][ 134 ][ 245 ][ 97 ][ !!! *54* !!! ]]
|
||||
[[ iterator_range<char*>->long double ][ 127 ][ 238 ][ 98 ][ !!! *59* !!! ]]
|
||||
[[ iterator_range<char*>->array<char, 50> ][ !!! *<1* !!! ][ 159 ][ 42 ][ 21 ]]
|
||||
[[ iterator_range<char*>->string ][ !!! *2* !!! ][ 165 ][ 50 ][ --- ]]
|
||||
[[ iterator_range<char*>->container::string ][ !!! *1* !!! ][ 186 ][ 58 ][ --- ]]
|
||||
[[ std::string_view->char ][ !!! *<1* !!! ][ 130 ][ 12 ][ 14 ]]
|
||||
[[ std::string_view->signed char ][ !!! *<1* !!! ][ 128 ][ 12 ][ 18 ]]
|
||||
[[ std::string_view->unsigned char ][ !!! *<1* !!! ][ 134 ][ 12 ][ 17 ]]
|
||||
[[ std::string_view->int ][ !!! *7* !!! ][ 153 ][ 31 ][ 27 ]]
|
||||
[[ std::string_view->short ][ !!! *7* !!! ][ 148 ][ 29 ][ 26 ]]
|
||||
[[ std::string_view->long int ][ !!! *7* !!! ][ 150 ][ 28 ][ 26 ]]
|
||||
[[ std::string_view->long long ][ !!! *7* !!! ][ 116 ][ 11 ][ 10 ]]
|
||||
[[ std::string_view->unsigned int ][ !!! *2* !!! ][ 57 ][ 10 ][ 10 ]]
|
||||
[[ std::string_view->unsigned short ][ !!! *3* !!! ][ 57 ][ 10 ][ 10 ]]
|
||||
[[ std::string_view->unsigned long int ][ !!! *2* !!! ][ 66 ][ 11 ][ 10 ]]
|
||||
[[ std::string_view->unsigned long long ][ !!! *2* !!! ][ 61 ][ 11 ][ 10 ]]
|
||||
[[ std::string_view->float ][ 52 ][ 90 ][ 31 ][ !!! *22* !!! ]]
|
||||
[[ std::string_view->double ][ 56 ][ 92 ][ 31 ][ !!! *22* !!! ]]
|
||||
[[ std::string_view->long double ][ 56 ][ 95 ][ 32 ][ !!! *24* !!! ]]
|
||||
[[ std::string_view->array<char, 50> ][ !!! *<1* !!! ][ 65 ][ 10 ][ 8 ]]
|
||||
[[ std::string_view->string ][ !!! *1* !!! ][ 60 ][ 12 ][ --- ]]
|
||||
[[ std::string_view->container::string ][ !!! *2* !!! ][ 67 ][ 14 ][ --- ]]
|
||||
[[ array<char, 50>->char ][ !!! *<1* !!! ][ 53 ][ 5 ][ 6 ]]
|
||||
[[ array<char, 50>->signed char ][ !!! *<1* !!! ][ 54 ][ 5 ][ 7 ]]
|
||||
[[ array<char, 50>->unsigned char ][ !!! *<1* !!! ][ 53 ][ 5 ][ 7 ]]
|
||||
[[ array<char, 50>->int ][ !!! *3* !!! ][ 63 ][ 12 ][ 11 ]]
|
||||
[[ array<char, 50>->short ][ !!! *3* !!! ][ 62 ][ 12 ][ 11 ]]
|
||||
[[ array<char, 50>->long int ][ !!! *3* !!! ][ 63 ][ 11 ][ 11 ]]
|
||||
[[ array<char, 50>->long long ][ !!! *3* !!! ][ 60 ][ 11 ][ 11 ]]
|
||||
[[ array<char, 50>->unsigned int ][ !!! *3* !!! ][ 57 ][ 10 ][ 11 ]]
|
||||
[[ array<char, 50>->unsigned short ][ !!! *3* !!! ][ 65 ][ 11 ][ 11 ]]
|
||||
[[ array<char, 50>->unsigned long int ][ !!! *3* !!! ][ 69 ][ 11 ][ 11 ]]
|
||||
[[ array<char, 50>->unsigned long long ][ !!! *3* !!! ][ 68 ][ 11 ][ 10 ]]
|
||||
[[ array<char, 50>->float ][ 54 ][ 82 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ array<char, 50>->double ][ 57 ][ 93 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ array<char, 50>->long double ][ 53 ][ 85 ][ 32 ][ !!! *23* !!! ]]
|
||||
[[ array<char, 50>->array<char, 50> ][ !!! *<1* !!! ][ 60 ][ 10 ][ 8 ]]
|
||||
[[ array<char, 50>->string ][ !!! *1* !!! ][ 61 ][ 11 ][ --- ]]
|
||||
[[ array<char, 50>->container::string ][ !!! *1* !!! ][ 62 ][ 15 ][ --- ]]
|
||||
[[ int->int ][ !!! *<1* !!! ][ 65 ][ 15 ][ --- ]]
|
||||
[[ float->double ][ !!! *<1* !!! ][ 138 ][ 68 ][ --- ]]
|
||||
[[ char->signed char ][ !!! *<1* !!! ][ 53 ][ 5 ][ --- ]]
|
||||
]
|
||||
[endsect]
|
||||
|
||||
[section GNU C++ version 10.5.0]
|
||||
[table:id Performance Table ( GNU C++ version 10.5.0)
|
||||
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
|
||||
[[ string->char ][ !!! *<1* !!! ][ 64 ][ 5 ][ 5 ]]
|
||||
[[ string->signed char ][ !!! *<1* !!! ][ 51 ][ 5 ][ 7 ]]
|
||||
[[ string->unsigned char ][ !!! *<1* !!! ][ 53 ][ 5 ][ 6 ]]
|
||||
[[ string->int ][ !!! *3* !!! ][ 56 ][ 11 ][ 10 ]]
|
||||
[[ string->short ][ !!! *3* !!! ][ 56 ][ 12 ][ 10 ]]
|
||||
[[ string->long int ][ !!! *3* !!! ][ 58 ][ 13 ][ 10 ]]
|
||||
[[ string->long long ][ !!! *3* !!! ][ 56 ][ 13 ][ 10 ]]
|
||||
[[ string->unsigned int ][ !!! *3* !!! ][ 60 ][ 10 ][ 10 ]]
|
||||
[[ string->unsigned short ][ !!! *3* !!! ][ 58 ][ 10 ][ 10 ]]
|
||||
[[ string->unsigned long int ][ !!! *3* !!! ][ 59 ][ 12 ][ 10 ]]
|
||||
[[ string->unsigned long long ][ !!! *3* !!! ][ 53 ][ 11 ][ 10 ]]
|
||||
[[ string->float ][ 49 ][ 81 ][ 34 ][ !!! *21* !!! ]]
|
||||
[[ string->double ][ 45 ][ 75 ][ 28 ][ !!! *21* !!! ]]
|
||||
[[ string->long double ][ 46 ][ 76 ][ 30 ][ !!! *25* !!! ]]
|
||||
[[ string->array<char, 50> ][ !!! *<1* !!! ][ 55 ][ 10 ][ 10 ]]
|
||||
[[ string->string ][ !!! *1* !!! ][ 54 ][ 11 ][ --- ]]
|
||||
[[ string->container::string ][ !!! *<1* !!! ][ 57 ][ 11 ][ --- ]]
|
||||
[[ string->char ][ !!! *<1* !!! ][ 51 ][ 9 ][ 7 ]]
|
||||
[[ string->signed char ][ !!! *<1* !!! ][ 51 ][ 10 ][ 10 ]]
|
||||
[[ string->unsigned char ][ !!! *<1* !!! ][ 53 ][ 10 ][ 10 ]]
|
||||
[[ int->string ][ !!! *3* !!! ][ 55 ][ 12 ][ 10 ]]
|
||||
[[ short->string ][ !!! *3* !!! ][ 55 ][ 13 ][ 10 ]]
|
||||
[[ long int->string ][ !!! *3* !!! ][ 55 ][ 12 ][ 10 ]]
|
||||
[[ long long->string ][ !!! *3* !!! ][ 56 ][ 12 ][ 10 ]]
|
||||
[[ unsigned int->string ][ !!! *3* !!! ][ 54 ][ 12 ][ 10 ]]
|
||||
[[ unsigned short->string ][ !!! *3* !!! ][ 54 ][ 12 ][ 10 ]]
|
||||
[[ unsigned long int->string ][ !!! *3* !!! ][ 55 ][ 12 ][ 10 ]]
|
||||
[[ unsigned long long->string ][ !!! *3* !!! ][ 55 ][ 12 ][ 10 ]]
|
||||
[[ float->string ][ 26 ][ 96 ][ 46 ][ !!! *25* !!! ]]
|
||||
[[ double->string ][ 33 ][ 94 ][ 46 ][ !!! *23* !!! ]]
|
||||
[[ long double->string ][ 44 ][ 96 ][ 52 ][ !!! *26* !!! ]]
|
||||
[[ char*->char ][ !!! *<1* !!! ][ 48 ][ 5 ][ 5 ]]
|
||||
[[ char*->signed char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 7 ]]
|
||||
[[ char*->unsigned char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 6 ]]
|
||||
[[ char*->int ][ !!! *3* !!! ][ 57 ][ 12 ][ 10 ]]
|
||||
[[ char*->short ][ !!! *3* !!! ][ 55 ][ 12 ][ 10 ]]
|
||||
[[ char*->long int ][ !!! *3* !!! ][ 59 ][ 11 ][ 10 ]]
|
||||
[[ char*->long long ][ !!! *4* !!! ][ 61 ][ 11 ][ 10 ]]
|
||||
[[ char*->unsigned int ][ !!! *3* !!! ][ 53 ][ 10 ][ 10 ]]
|
||||
[[ char*->unsigned short ][ !!! *3* !!! ][ 53 ][ 10 ][ 10 ]]
|
||||
[[ char*->unsigned long int ][ !!! *3* !!! ][ 54 ][ 11 ][ 10 ]]
|
||||
[[ char*->unsigned long long ][ !!! *3* !!! ][ 55 ][ 11 ][ 10 ]]
|
||||
[[ char*->float ][ 46 ][ 78 ][ 39 ][ !!! *21* !!! ]]
|
||||
[[ char*->double ][ 43 ][ 73 ][ 28 ][ !!! *21* !!! ]]
|
||||
[[ char*->long double ][ 46 ][ 74 ][ 30 ][ !!! *23* !!! ]]
|
||||
[[ char*->array<char, 50> ][ !!! *<1* !!! ][ 52 ][ 10 ][ 8 ]]
|
||||
[[ char*->string ][ !!! *1* !!! ][ 58 ][ 11 ][ --- ]]
|
||||
[[ char*->container::string ][ !!! *<1* !!! ][ 64 ][ 11 ][ --- ]]
|
||||
[[ unsigned char*->char ][ !!! *<1* !!! ][ 52 ][ 4 ][ 4 ]]
|
||||
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 54 ][ 4 ][ 5 ]]
|
||||
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 54 ][ 4 ][ 5 ]]
|
||||
[[ unsigned char*->int ][ !!! *4* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ unsigned char*->short ][ !!! *4* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ unsigned char*->long int ][ !!! *4* !!! ][ 66 ][ 24 ][ 19 ]]
|
||||
[[ unsigned char*->long long ][ !!! *4* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ unsigned char*->unsigned int ][ !!! *4* !!! ][ 79 ][ 24 ][ 22 ]]
|
||||
[[ unsigned char*->unsigned short ][ !!! *7* !!! ][ 123 ][ 23 ][ 22 ]]
|
||||
[[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 121 ][ 24 ][ 22 ]]
|
||||
[[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 121 ][ 24 ][ 22 ]]
|
||||
[[ unsigned char*->float ][ 97 ][ 167 ][ 67 ][ !!! *47* !!! ]]
|
||||
[[ unsigned char*->double ][ 96 ][ 164 ][ 67 ][ !!! *47* !!! ]]
|
||||
[[ unsigned char*->long double ][ 97 ][ 165 ][ 66 ][ !!! *47* !!! ]]
|
||||
[[ unsigned char*->array<char, 50> ][ !!! *<1* !!! ][ 119 ][ 22 ][ 17 ]]
|
||||
[[ unsigned char*->string ][ !!! *11* !!! ][ 139 ][ 34 ][ --- ]]
|
||||
[[ unsigned char*->container::string ][ !!! *1* !!! ][ 121 ][ 25 ][ --- ]]
|
||||
[[ signed char*->char ][ !!! *<1* !!! ][ 106 ][ 11 ][ 8 ]]
|
||||
[[ signed char*->signed char ][ !!! *<1* !!! ][ 81 ][ 12 ][ 13 ]]
|
||||
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 109 ][ 11 ][ 12 ]]
|
||||
[[ signed char*->int ][ !!! *7* !!! ][ 122 ][ 24 ][ 21 ]]
|
||||
[[ signed char*->short ][ !!! *4* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ signed char*->long int ][ !!! *4* !!! ][ 60 ][ 10 ][ 8 ]]
|
||||
[[ signed char*->long long ][ !!! *4* !!! ][ 60 ][ 10 ][ 8 ]]
|
||||
[[ signed char*->unsigned int ][ !!! *4* !!! ][ 64 ][ 23 ][ 22 ]]
|
||||
[[ signed char*->unsigned short ][ !!! *7* !!! ][ 120 ][ 24 ][ 22 ]]
|
||||
[[ signed char*->unsigned long int ][ !!! *8* !!! ][ 121 ][ 24 ][ 22 ]]
|
||||
[[ signed char*->unsigned long long ][ !!! *8* !!! ][ 122 ][ 23 ][ 22 ]]
|
||||
[[ signed char*->float ][ 95 ][ 165 ][ 68 ][ !!! *46* !!! ]]
|
||||
[[ signed char*->double ][ 95 ][ 161 ][ 66 ][ !!! *47* !!! ]]
|
||||
[[ signed char*->long double ][ 96 ][ 161 ][ 66 ][ !!! *46* !!! ]]
|
||||
[[ signed char*->array<char, 50> ][ !!! *<1* !!! ][ 117 ][ 22 ][ 17 ]]
|
||||
[[ signed char*->string ][ !!! *10* !!! ][ 84 ][ 15 ][ --- ]]
|
||||
[[ signed char*->container::string ][ !!! *1* !!! ][ 119 ][ 25 ][ --- ]]
|
||||
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 111 ][ 16 ][ 11 ]]
|
||||
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 110 ][ 16 ][ 13 ]]
|
||||
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 111 ][ 15 ][ 13 ]]
|
||||
[[ iterator_range<char*>->int ][ !!! *6* !!! ][ 119 ][ 25 ][ 22 ]]
|
||||
[[ iterator_range<char*>->short ][ !!! *7* !!! ][ 119 ][ 25 ][ 22 ]]
|
||||
[[ iterator_range<char*>->long int ][ !!! *7* !!! ][ 120 ][ 25 ][ 22 ]]
|
||||
[[ iterator_range<char*>->long long ][ !!! *8* !!! ][ 119 ][ 24 ][ 22 ]]
|
||||
[[ iterator_range<char*>->unsigned int ][ !!! *6* !!! ][ 119 ][ 24 ][ 22 ]]
|
||||
[[ iterator_range<char*>->unsigned short ][ !!! *6* !!! ][ 117 ][ 24 ][ 22 ]]
|
||||
[[ iterator_range<char*>->unsigned long int ][ !!! *7* !!! ][ 120 ][ 24 ][ 22 ]]
|
||||
[[ iterator_range<char*>->unsigned long long ][ !!! *8* !!! ][ 118 ][ 24 ][ 22 ]]
|
||||
[[ iterator_range<char*>->float ][ 96 ][ 155 ][ 48 ][ !!! *47* !!! ]]
|
||||
[[ iterator_range<char*>->double ][ 96 ][ 141 ][ 47 ][ !!! *47* !!! ]]
|
||||
[[ iterator_range<char*>->long double ][ 96 ][ 140 ][ 46 ][ !!! *46* !!! ]]
|
||||
[[ iterator_range<char*>->array<char, 50> ][ !!! *<1* !!! ][ 118 ][ 25 ][ 17 ]]
|
||||
[[ iterator_range<char*>->string ][ !!! *10* !!! ][ 136 ][ 35 ][ --- ]]
|
||||
[[ iterator_range<char*>->container::string ][ !!! *1* !!! ][ 119 ][ 26 ][ --- ]]
|
||||
[[ array<char, 50>->char ][ !!! *<1* !!! ][ 108 ][ 11 ][ 10 ]]
|
||||
[[ array<char, 50>->signed char ][ !!! *<1* !!! ][ 106 ][ 12 ][ 12 ]]
|
||||
[[ array<char, 50>->unsigned char ][ !!! *<1* !!! ][ 107 ][ 11 ][ 13 ]]
|
||||
[[ array<char, 50>->int ][ !!! *6* !!! ][ 119 ][ 24 ][ 22 ]]
|
||||
[[ array<char, 50>->short ][ !!! *7* !!! ][ 121 ][ 24 ][ 22 ]]
|
||||
[[ array<char, 50>->long int ][ !!! *7* !!! ][ 119 ][ 24 ][ 22 ]]
|
||||
[[ array<char, 50>->long long ][ !!! *7* !!! ][ 123 ][ 24 ][ 22 ]]
|
||||
[[ array<char, 50>->unsigned int ][ !!! *7* !!! ][ 121 ][ 23 ][ 25 ]]
|
||||
[[ array<char, 50>->unsigned short ][ !!! *6* !!! ][ 120 ][ 24 ][ 22 ]]
|
||||
[[ array<char, 50>->unsigned long int ][ !!! *7* !!! ][ 59 ][ 10 ][ 9 ]]
|
||||
[[ array<char, 50>->unsigned long long ][ !!! *4* !!! ][ 60 ][ 10 ][ 8 ]]
|
||||
[[ array<char, 50>->float ][ 47 ][ 80 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ array<char, 50>->double ][ 46 ][ 82 ][ 31 ][ !!! *22* !!! ]]
|
||||
[[ array<char, 50>->long double ][ 49 ][ 82 ][ 31 ][ !!! *22* !!! ]]
|
||||
[[ array<char, 50>->array<char, 50> ][ !!! *1* !!! ][ 59 ][ 9 ][ 7 ]]
|
||||
[[ array<char, 50>->string ][ !!! *5* !!! ][ 70 ][ 15 ][ --- ]]
|
||||
[[ array<char, 50>->container::string ][ !!! *1* !!! ][ 60 ][ 11 ][ --- ]]
|
||||
[[ int->int ][ !!! *<1* !!! ][ 61 ][ 12 ][ --- ]]
|
||||
[[ float->double ][ !!! *<1* !!! ][ 111 ][ 54 ][ --- ]]
|
||||
[[ char->signed char ][ !!! *<1* !!! ][ 51 ][ 4 ][ --- ]]
|
||||
[[ unsigned char*->char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 5 ]]
|
||||
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 7 ]]
|
||||
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 7 ]]
|
||||
[[ unsigned char*->int ][ !!! *3* !!! ][ 55 ][ 12 ][ 12 ]]
|
||||
[[ unsigned char*->short ][ !!! *4* !!! ][ 59 ][ 11 ][ 10 ]]
|
||||
[[ unsigned char*->long int ][ !!! *3* !!! ][ 56 ][ 12 ][ 10 ]]
|
||||
[[ unsigned char*->long long ][ !!! *3* !!! ][ 55 ][ 12 ][ 10 ]]
|
||||
[[ unsigned char*->unsigned int ][ !!! *3* !!! ][ 53 ][ 10 ][ 10 ]]
|
||||
[[ unsigned char*->unsigned short ][ !!! *3* !!! ][ 54 ][ 10 ][ 10 ]]
|
||||
[[ unsigned char*->unsigned long int ][ !!! *3* !!! ][ 54 ][ 11 ][ 10 ]]
|
||||
[[ unsigned char*->unsigned long long ][ !!! *3* !!! ][ 55 ][ 11 ][ 10 ]]
|
||||
[[ unsigned char*->float ][ 100 ][ 143 ][ 33 ][ !!! *21* !!! ]]
|
||||
[[ unsigned char*->double ][ 44 ][ 73 ][ 28 ][ !!! *22* !!! ]]
|
||||
[[ unsigned char*->long double ][ 46 ][ 75 ][ 30 ][ !!! *23* !!! ]]
|
||||
[[ unsigned char*->array<char, 50> ][ !!! *<1* !!! ][ 53 ][ 11 ][ 8 ]]
|
||||
[[ unsigned char*->string ][ !!! *1* !!! ][ 58 ][ 11 ][ --- ]]
|
||||
[[ unsigned char*->container::string ][ !!! *<1* !!! ][ 59 ][ 11 ][ --- ]]
|
||||
[[ signed char*->char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 5 ]]
|
||||
[[ signed char*->signed char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 7 ]]
|
||||
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 51 ][ 5 ][ 6 ]]
|
||||
[[ signed char*->int ][ !!! *3* !!! ][ 55 ][ 12 ][ 10 ]]
|
||||
[[ signed char*->short ][ !!! *4* !!! ][ 56 ][ 12 ][ 10 ]]
|
||||
[[ signed char*->long int ][ !!! *4* !!! ][ 56 ][ 11 ][ 10 ]]
|
||||
[[ signed char*->long long ][ !!! *3* !!! ][ 55 ][ 11 ][ 10 ]]
|
||||
[[ signed char*->unsigned int ][ !!! *3* !!! ][ 60 ][ 10 ][ 10 ]]
|
||||
[[ signed char*->unsigned short ][ !!! *3* !!! ][ 53 ][ 10 ][ 10 ]]
|
||||
[[ signed char*->unsigned long int ][ !!! *3* !!! ][ 54 ][ 11 ][ 10 ]]
|
||||
[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 58 ][ 11 ][ 10 ]]
|
||||
[[ signed char*->float ][ 47 ][ 76 ][ 32 ][ !!! *21* !!! ]]
|
||||
[[ signed char*->double ][ 44 ][ 73 ][ 29 ][ !!! *21* !!! ]]
|
||||
[[ signed char*->long double ][ 45 ][ 74 ][ 31 ][ !!! *24* !!! ]]
|
||||
[[ signed char*->array<char, 50> ][ !!! *<1* !!! ][ 52 ][ 11 ][ 8 ]]
|
||||
[[ signed char*->string ][ !!! *1* !!! ][ 58 ][ 11 ][ --- ]]
|
||||
[[ signed char*->container::string ][ !!! *<1* !!! ][ 59 ][ 11 ][ --- ]]
|
||||
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 5 ]]
|
||||
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 7 ]]
|
||||
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 53 ][ 5 ][ 6 ]]
|
||||
[[ iterator_range<char*>->int ][ !!! *3* !!! ][ 58 ][ 15 ][ 10 ]]
|
||||
[[ iterator_range<char*>->short ][ !!! *3* !!! ][ 59 ][ 16 ][ 10 ]]
|
||||
[[ iterator_range<char*>->long int ][ !!! *3* !!! ][ 58 ][ 15 ][ 10 ]]
|
||||
[[ iterator_range<char*>->long long ][ !!! *3* !!! ][ 59 ][ 15 ][ 10 ]]
|
||||
[[ iterator_range<char*>->unsigned int ][ !!! *3* !!! ][ 56 ][ 14 ][ 10 ]]
|
||||
[[ iterator_range<char*>->unsigned short ][ !!! *3* !!! ][ 61 ][ 14 ][ 10 ]]
|
||||
[[ iterator_range<char*>->unsigned long int ][ !!! *3* !!! ][ 58 ][ 14 ][ 10 ]]
|
||||
[[ iterator_range<char*>->unsigned long long ][ !!! *3* !!! ][ 71 ][ 36 ][ 25 ]]
|
||||
[[ iterator_range<char*>->float ][ 116 ][ 93 ][ 39 ][ !!! *21* !!! ]]
|
||||
[[ iterator_range<char*>->double ][ 43 ][ 81 ][ 34 ][ !!! *21* !!! ]]
|
||||
[[ iterator_range<char*>->long double ][ 44 ][ 87 ][ 37 ][ !!! *24* !!! ]]
|
||||
[[ iterator_range<char*>->array<char, 50> ][ !!! *<1* !!! ][ 58 ][ 17 ][ 8 ]]
|
||||
[[ iterator_range<char*>->string ][ !!! *1* !!! ][ 63 ][ 20 ][ --- ]]
|
||||
[[ iterator_range<char*>->container::string ][ !!! *<1* !!! ][ 65 ][ 20 ][ --- ]]
|
||||
[[ std::string_view->char ][ !!! *<1* !!! ][ 46 ][ 5 ][ 5 ]]
|
||||
[[ std::string_view->signed char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 7 ]]
|
||||
[[ std::string_view->unsigned char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 7 ]]
|
||||
[[ std::string_view->int ][ !!! *4* !!! ][ 56 ][ 11 ][ 10 ]]
|
||||
[[ std::string_view->short ][ !!! *3* !!! ][ 55 ][ 12 ][ 10 ]]
|
||||
[[ std::string_view->long int ][ !!! *4* !!! ][ 54 ][ 11 ][ 10 ]]
|
||||
[[ std::string_view->long long ][ !!! *4* !!! ][ 54 ][ 11 ][ 10 ]]
|
||||
[[ std::string_view->unsigned int ][ !!! *3* !!! ][ 53 ][ 10 ][ 10 ]]
|
||||
[[ std::string_view->unsigned short ][ !!! *3* !!! ][ 54 ][ 10 ][ 10 ]]
|
||||
[[ std::string_view->unsigned long int ][ !!! *3* !!! ][ 54 ][ 11 ][ 10 ]]
|
||||
[[ std::string_view->unsigned long long ][ !!! *3* !!! ][ 55 ][ 11 ][ 10 ]]
|
||||
[[ std::string_view->float ][ 47 ][ 76 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ std::string_view->double ][ 43 ][ 74 ][ 28 ][ !!! *21* !!! ]]
|
||||
[[ std::string_view->long double ][ 46 ][ 75 ][ 31 ][ !!! *24* !!! ]]
|
||||
[[ std::string_view->array<char, 50> ][ !!! *1* !!! ][ 51 ][ 10 ][ 8 ]]
|
||||
[[ std::string_view->string ][ !!! *2* !!! ][ 53 ][ 10 ][ --- ]]
|
||||
[[ std::string_view->container::string ][ !!! *1* !!! ][ 56 ][ 11 ][ --- ]]
|
||||
[[ array<char, 50>->char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 5 ]]
|
||||
[[ array<char, 50>->signed char ][ !!! *<1* !!! ][ 47 ][ 5 ][ 6 ]]
|
||||
[[ array<char, 50>->unsigned char ][ !!! *<1* !!! ][ 49 ][ 5 ][ 6 ]]
|
||||
[[ array<char, 50>->int ][ !!! *3* !!! ][ 54 ][ 12 ][ 10 ]]
|
||||
[[ array<char, 50>->short ][ !!! *3* !!! ][ 61 ][ 11 ][ 10 ]]
|
||||
[[ array<char, 50>->long int ][ !!! *3* !!! ][ 55 ][ 11 ][ 10 ]]
|
||||
[[ array<char, 50>->long long ][ !!! *3* !!! ][ 54 ][ 11 ][ 10 ]]
|
||||
[[ array<char, 50>->unsigned int ][ !!! *3* !!! ][ 53 ][ 10 ][ 10 ]]
|
||||
[[ array<char, 50>->unsigned short ][ !!! *3* !!! ][ 52 ][ 10 ][ 10 ]]
|
||||
[[ array<char, 50>->unsigned long int ][ !!! *3* !!! ][ 62 ][ 11 ][ 10 ]]
|
||||
[[ array<char, 50>->unsigned long long ][ !!! *3* !!! ][ 54 ][ 11 ][ 10 ]]
|
||||
[[ array<char, 50>->float ][ 45 ][ 75 ][ 35 ][ !!! *24* !!! ]]
|
||||
[[ array<char, 50>->double ][ 44 ][ 75 ][ 28 ][ !!! *21* !!! ]]
|
||||
[[ array<char, 50>->long double ][ 45 ][ 76 ][ 29 ][ !!! *24* !!! ]]
|
||||
[[ array<char, 50>->array<char, 50> ][ !!! *<1* !!! ][ 53 ][ 10 ][ 8 ]]
|
||||
[[ array<char, 50>->string ][ !!! *1* !!! ][ 54 ][ 11 ][ --- ]]
|
||||
[[ array<char, 50>->container::string ][ !!! *1* !!! ][ 56 ][ 12 ][ --- ]]
|
||||
[[ int->int ][ !!! *<1* !!! ][ 58 ][ 13 ][ --- ]]
|
||||
[[ float->double ][ !!! *<1* !!! ][ 116 ][ 63 ][ --- ]]
|
||||
[[ char->signed char ][ !!! *<1* !!! ][ 47 ][ 5 ][ --- ]]
|
||||
]
|
||||
[endsect]
|
||||
|
||||
[section GNU C++ version 4.8.5]
|
||||
[table:id Performance Table ( GNU C++ version 4.8.5)
|
||||
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
|
||||
[[ string->char ][ !!! *<1* !!! ][ 100 ][ 10 ][ 10 ]]
|
||||
[[ string->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ 11 ]]
|
||||
[[ string->unsigned char ][ !!! *<1* !!! ][ 103 ][ 11 ][ 13 ]]
|
||||
[[ string->int ][ !!! *6* !!! ][ 122 ][ 23 ][ 22 ]]
|
||||
[[ string->short ][ !!! *6* !!! ][ 116 ][ 23 ][ 22 ]]
|
||||
[[ string->long int ][ !!! *6* !!! ][ 97 ][ 21 ][ 22 ]]
|
||||
[[ string->long long ][ !!! *7* !!! ][ 118 ][ 22 ][ 22 ]]
|
||||
[[ string->unsigned int ][ !!! *6* !!! ][ 116 ][ 22 ][ 22 ]]
|
||||
[[ string->unsigned short ][ !!! *6* !!! ][ 106 ][ 9 ][ 8 ]]
|
||||
[[ string->unsigned long int ][ !!! *3* !!! ][ 59 ][ 9 ][ 8 ]]
|
||||
[[ string->unsigned long long ][ !!! *3* !!! ][ 58 ][ 9 ][ 8 ]]
|
||||
[[ string->float ][ 88 ][ 166 ][ 70 ][ !!! *47* !!! ]]
|
||||
[[ string->double ][ 102 ][ 162 ][ 65 ][ !!! *51* !!! ]]
|
||||
[[ string->long double ][ 96 ][ 163 ][ 71 ][ !!! *46* !!! ]]
|
||||
[[ string->array<char, 50> ][ !!! *1* !!! ][ 112 ][ 21 ][ 18 ]]
|
||||
[[ string->string ][ !!! *2* !!! ][ 139 ][ 37 ][ --- ]]
|
||||
[[ string->container::string ][ !!! *1* !!! ][ 121 ][ 24 ][ --- ]]
|
||||
[[ string->char ][ !!! *9* !!! ][ 121 ][ 31 ][ 21 ]]
|
||||
[[ string->signed char ][ !!! *9* !!! ][ 121 ][ 31 ][ 34 ]]
|
||||
[[ string->unsigned char ][ !!! *9* !!! ][ 120 ][ 31 ][ 30 ]]
|
||||
[[ int->string ][ !!! *17* !!! ][ 141 ][ 39 ][ 30 ]]
|
||||
[[ short->string ][ !!! *18* !!! ][ 142 ][ 39 ][ 30 ]]
|
||||
[[ long int->string ][ 17 ][ 136 ][ 17 ][ !!! *12* !!! ]]
|
||||
[[ long long->string ][ !!! *7* !!! ][ 69 ][ 17 ][ 13 ]]
|
||||
[[ unsigned int->string ][ !!! *8* !!! ][ 70 ][ 24 ][ 13 ]]
|
||||
[[ unsigned short->string ][ !!! *7* !!! ][ 69 ][ 17 ][ 12 ]]
|
||||
[[ unsigned long int->string ][ !!! *7* !!! ][ 71 ][ 16 ][ 12 ]]
|
||||
[[ unsigned long long->string ][ !!! *7* !!! ][ 71 ][ 16 ][ 12 ]]
|
||||
[[ float->string ][ 60 ][ 95 ][ 49 ][ !!! *24* !!! ]]
|
||||
[[ double->string ][ 68 ][ 97 ][ 45 ][ !!! *26* !!! ]]
|
||||
[[ long double->string ][ 72 ][ 108 ][ 45 ][ !!! *28* !!! ]]
|
||||
[[ char*->char ][ !!! *<1* !!! ][ 52 ][ 5 ][ 4 ]]
|
||||
[[ char*->signed char ][ !!! *<1* !!! ][ 52 ][ 5 ][ 5 ]]
|
||||
[[ char*->unsigned char ][ !!! *<1* !!! ][ 52 ][ 5 ][ 5 ]]
|
||||
[[ char*->int ][ !!! *3* !!! ][ 60 ][ 10 ][ 8 ]]
|
||||
[[ char*->short ][ !!! *3* !!! ][ 61 ][ 10 ][ 8 ]]
|
||||
[[ char*->long int ][ !!! *4* !!! ][ 60 ][ 10 ][ 8 ]]
|
||||
[[ char*->long long ][ !!! *4* !!! ][ 61 ][ 9 ][ 8 ]]
|
||||
[[ char*->unsigned int ][ !!! *3* !!! ][ 103 ][ 13 ][ 8 ]]
|
||||
[[ char*->unsigned short ][ !!! *3* !!! ][ 97 ][ 23 ][ 22 ]]
|
||||
[[ char*->unsigned long int ][ !!! *7* !!! ][ 123 ][ 23 ][ 22 ]]
|
||||
[[ char*->unsigned long long ][ !!! *6* !!! ][ 72 ][ 10 ][ 8 ]]
|
||||
[[ char*->float ][ 85 ][ 160 ][ 66 ][ !!! *47* !!! ]]
|
||||
[[ char*->double ][ 94 ][ 161 ][ 65 ][ !!! *46* !!! ]]
|
||||
[[ char*->long double ][ 94 ][ 172 ][ 64 ][ !!! *47* !!! ]]
|
||||
[[ char*->array<char, 50> ][ !!! *2* !!! ][ 113 ][ 22 ][ 16 ]]
|
||||
[[ char*->string ][ !!! *10* !!! ][ 145 ][ 34 ][ --- ]]
|
||||
[[ char*->container::string ][ !!! *1* !!! ][ 120 ][ 25 ][ --- ]]
|
||||
[[ unsigned char*->char ][ !!! *<1* !!! ][ 102 ][ 11 ][ 10 ]]
|
||||
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 100 ][ 12 ][ 12 ]]
|
||||
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 102 ][ 11 ][ 12 ]]
|
||||
[[ unsigned char*->int ][ !!! *7* !!! ][ 119 ][ 24 ][ 22 ]]
|
||||
[[ unsigned char*->short ][ !!! *7* !!! ][ 120 ][ 24 ][ 22 ]]
|
||||
[[ unsigned char*->long int ][ !!! *7* !!! ][ 119 ][ 24 ][ 23 ]]
|
||||
[[ unsigned char*->long long ][ !!! *7* !!! ][ 119 ][ 24 ][ 22 ]]
|
||||
[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 82 ][ 9 ][ 8 ]]
|
||||
[[ unsigned char*->unsigned short ][ !!! *3* !!! ][ 58 ][ 9 ][ 8 ]]
|
||||
[[ unsigned char*->unsigned long int ][ !!! *4* !!! ][ 59 ][ 10 ][ 10 ]]
|
||||
[[ unsigned char*->unsigned long long ][ !!! *4* !!! ][ 60 ][ 12 ][ 8 ]]
|
||||
[[ unsigned char*->float ][ 47 ][ 80 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ unsigned char*->double ][ 47 ][ 79 ][ 31 ][ !!! *23* !!! ]]
|
||||
[[ unsigned char*->long double ][ 47 ][ 80 ][ 31 ][ !!! *22* !!! ]]
|
||||
[[ unsigned char*->array<char, 50> ][ !!! *1* !!! ][ 58 ][ 9 ][ 7 ]]
|
||||
[[ unsigned char*->string ][ !!! *4* !!! ][ 68 ][ 15 ][ --- ]]
|
||||
[[ unsigned char*->container::string ][ !!! *<1* !!! ][ 60 ][ 10 ][ --- ]]
|
||||
[[ signed char*->char ][ !!! *<1* !!! ][ 52 ][ 5 ][ 4 ]]
|
||||
[[ signed char*->signed char ][ !!! *<1* !!! ][ 54 ][ 4 ][ 5 ]]
|
||||
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 52 ][ 4 ][ 6 ]]
|
||||
[[ signed char*->int ][ !!! *6* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ signed char*->short ][ !!! *3* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ signed char*->long int ][ !!! *4* !!! ][ 60 ][ 10 ][ 8 ]]
|
||||
[[ signed char*->long long ][ !!! *4* !!! ][ 59 ][ 10 ][ 9 ]]
|
||||
[[ signed char*->unsigned int ][ !!! *3* !!! ][ 58 ][ 9 ][ 8 ]]
|
||||
[[ signed char*->unsigned short ][ !!! *4* !!! ][ 58 ][ 9 ][ 8 ]]
|
||||
[[ signed char*->unsigned long int ][ !!! *4* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ signed char*->unsigned long long ][ !!! *4* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ signed char*->float ][ 47 ][ 81 ][ 32 ][ !!! *25* !!! ]]
|
||||
[[ signed char*->double ][ 46 ][ 79 ][ 31 ][ !!! *22* !!! ]]
|
||||
[[ signed char*->long double ][ 48 ][ 80 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ signed char*->array<char, 50> ][ !!! *1* !!! ][ 63 ][ 9 ][ 7 ]]
|
||||
[[ signed char*->string ][ !!! *4* !!! ][ 68 ][ 15 ][ --- ]]
|
||||
[[ signed char*->container::string ][ !!! *<1* !!! ][ 58 ][ 10 ][ --- ]]
|
||||
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 54 ][ 6 ][ 4 ]]
|
||||
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 57 ][ 6 ][ 5 ]]
|
||||
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 54 ][ 6 ][ 5 ]]
|
||||
[[ iterator_range<char*>->int ][ !!! *3* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ iterator_range<char*>->short ][ !!! *3* !!! ][ 59 ][ 11 ][ 9 ]]
|
||||
[[ iterator_range<char*>->long int ][ !!! *3* !!! ][ 61 ][ 11 ][ 8 ]]
|
||||
[[ iterator_range<char*>->long long ][ !!! *3* !!! ][ 59 ][ 10 ][ 9 ]]
|
||||
[[ iterator_range<char*>->unsigned int ][ !!! *3* !!! ][ 57 ][ 9 ][ 8 ]]
|
||||
[[ iterator_range<char*>->unsigned short ][ !!! *3* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ iterator_range<char*>->unsigned long int ][ !!! *3* !!! ][ 58 ][ 10 ][ 8 ]]
|
||||
[[ iterator_range<char*>->unsigned long long ][ !!! *3* !!! ][ 58 ][ 15 ][ 8 ]]
|
||||
[[ iterator_range<char*>->float ][ 46 ][ 78 ][ 22 ][ !!! *22* !!! ]]
|
||||
[[ iterator_range<char*>->double ][ 94 ][ 85 ][ !!! *21* !!! ][ 22 ]]
|
||||
[[ iterator_range<char*>->long double ][ 47 ][ 79 ][ 33 ][ !!! *22* !!! ]]
|
||||
[[ iterator_range<char*>->array<char, 50> ][ !!! *1* !!! ][ 102 ][ 25 ][ 16 ]]
|
||||
[[ iterator_range<char*>->string ][ !!! *10* !!! ][ 96 ][ 16 ][ --- ]]
|
||||
[[ iterator_range<char*>->container::string ][ !!! *<1* !!! ][ 64 ][ 11 ][ --- ]]
|
||||
[[ array<char, 50>->char ][ !!! *<1* !!! ][ 75 ][ 4 ][ 4 ]]
|
||||
[[ array<char, 50>->signed char ][ !!! *<1* !!! ][ 54 ][ 6 ][ 13 ]]
|
||||
[[ array<char, 50>->unsigned char ][ !!! *<1* !!! ][ 103 ][ 12 ][ 12 ]]
|
||||
[[ array<char, 50>->int ][ !!! *6* !!! ][ 121 ][ 25 ][ 23 ]]
|
||||
[[ array<char, 50>->short ][ !!! *7* !!! ][ 122 ][ 24 ][ 22 ]]
|
||||
[[ array<char, 50>->long int ][ !!! *7* !!! ][ 119 ][ 24 ][ 22 ]]
|
||||
[[ array<char, 50>->long long ][ !!! *7* !!! ][ 120 ][ 24 ][ 22 ]]
|
||||
[[ array<char, 50>->unsigned int ][ !!! *6* !!! ][ 121 ][ 23 ][ 22 ]]
|
||||
[[ array<char, 50>->unsigned short ][ !!! *6* !!! ][ 121 ][ 23 ][ 22 ]]
|
||||
[[ array<char, 50>->unsigned long int ][ !!! *6* !!! ][ 118 ][ 24 ][ 20 ]]
|
||||
[[ array<char, 50>->unsigned long long ][ !!! *6* !!! ][ 109 ][ 22 ][ 21 ]]
|
||||
[[ array<char, 50>->float ][ 93 ][ 150 ][ 61 ][ !!! *43* !!! ]]
|
||||
[[ array<char, 50>->double ][ 89 ][ 147 ][ 61 ][ !!! *43* !!! ]]
|
||||
[[ array<char, 50>->long double ][ 91 ][ 148 ][ 61 ][ !!! *42* !!! ]]
|
||||
[[ array<char, 50>->array<char, 50> ][ !!! *2* !!! ][ 106 ][ 21 ][ 15 ]]
|
||||
[[ array<char, 50>->string ][ !!! *10* !!! ][ 124 ][ 32 ][ --- ]]
|
||||
[[ array<char, 50>->container::string ][ !!! *1* !!! ][ 109 ][ 23 ][ --- ]]
|
||||
[[ int->int ][ !!! *<1* !!! ][ 114 ][ 26 ][ --- ]]
|
||||
[[ float->double ][ !!! *<1* !!! ][ 207 ][ 105 ][ --- ]]
|
||||
[[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 10 ][ --- ]]
|
||||
]
|
||||
[endsect]
|
||||
|
||||
[section Clang version 3.6.0 (tags/RELEASE_360/final)]
|
||||
[table:id Performance Table ( Clang version 3.6.0 (tags/RELEASE_360/final))
|
||||
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
|
||||
[[ string->char ][ !!! *<1* !!! ][ 79 ][ 4 ][ 4 ]]
|
||||
[[ string->signed char ][ !!! *<1* !!! ][ 51 ][ 4 ][ 5 ]]
|
||||
[[ string->unsigned char ][ !!! *<1* !!! ][ 51 ][ 4 ][ 5 ]]
|
||||
[[ string->int ][ !!! *3* !!! ][ 80 ][ 22 ][ 22 ]]
|
||||
[[ string->short ][ !!! *6* !!! ][ 108 ][ 22 ][ 22 ]]
|
||||
[[ string->long int ][ !!! *6* !!! ][ 66 ][ 10 ][ 11 ]]
|
||||
[[ string->long long ][ !!! *6* !!! ][ 101 ][ 9 ][ 20 ]]
|
||||
[[ string->unsigned int ][ !!! *5* !!! ][ 77 ][ 8 ][ 8 ]]
|
||||
[[ string->unsigned short ][ !!! *3* !!! ][ 61 ][ 8 ][ 8 ]]
|
||||
[[ string->unsigned long int ][ !!! *5* !!! ][ 87 ][ 9 ][ 9 ]]
|
||||
[[ string->unsigned long long ][ !!! *3* !!! ][ 89 ][ 9 ][ 8 ]]
|
||||
[[ string->float ][ 52 ][ 114 ][ 38 ][ !!! *22* !!! ]]
|
||||
[[ string->double ][ 49 ][ 79 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ string->long double ][ 83 ][ 160 ][ 65 ][ !!! *47* !!! ]]
|
||||
[[ string->array<char, 50> ][ !!! *<1* !!! ][ 114 ][ 21 ][ 16 ]]
|
||||
[[ string->string ][ !!! *2* !!! ][ 78 ][ 34 ][ --- ]]
|
||||
[[ string->container::string ][ !!! *1* !!! ][ 100 ][ 11 ][ --- ]]
|
||||
[[ string->char ][ !!! *4* !!! ][ 60 ][ 16 ][ 7 ]]
|
||||
[[ string->signed char ][ !!! *5* !!! ][ 70 ][ 30 ][ 30 ]]
|
||||
[[ string->unsigned char ][ !!! *10* !!! ][ 119 ][ 31 ][ 30 ]]
|
||||
[[ int->string ][ !!! *17* !!! ][ 140 ][ 38 ][ 28 ]]
|
||||
[[ short->string ][ !!! *17* !!! ][ 139 ][ 38 ][ 29 ]]
|
||||
[[ long int->string ][ !!! *17* !!! ][ 139 ][ 37 ][ 29 ]]
|
||||
[[ long long->string ][ !!! *18* !!! ][ 138 ][ 37 ][ 30 ]]
|
||||
[[ unsigned int->string ][ !!! *17* !!! ][ 138 ][ 37 ][ 29 ]]
|
||||
[[ unsigned short->string ][ !!! *17* !!! ][ 139 ][ 38 ][ 29 ]]
|
||||
[[ unsigned long int->string ][ !!! *17* !!! ][ 142 ][ 37 ][ 29 ]]
|
||||
[[ unsigned long long->string ][ !!! *8* !!! ][ 71 ][ 16 ][ 28 ]]
|
||||
[[ float->string ][ 68 ][ 97 ][ 42 ][ !!! *38* !!! ]]
|
||||
[[ double->string ][ 68 ][ 134 ][ 43 ][ !!! *25* !!! ]]
|
||||
[[ long double->string ][ 72 ][ 164 ][ 91 ][ !!! *55* !!! ]]
|
||||
[[ char*->char ][ !!! *<1* !!! ][ 76 ][ 4 ][ 5 ]]
|
||||
[[ char*->signed char ][ !!! *<1* !!! ][ 54 ][ 5 ][ 5 ]]
|
||||
[[ char*->unsigned char ][ !!! *<1* !!! ][ 55 ][ 4 ][ 5 ]]
|
||||
[[ char*->int ][ !!! *3* !!! ][ 60 ][ 10 ][ 8 ]]
|
||||
[[ char*->short ][ !!! *3* !!! ][ 61 ][ 9 ][ 8 ]]
|
||||
[[ char*->long int ][ !!! *4* !!! ][ 61 ][ 9 ][ 8 ]]
|
||||
[[ char*->long long ][ !!! *3* !!! ][ 60 ][ 9 ][ 8 ]]
|
||||
[[ char*->unsigned int ][ !!! *3* !!! ][ 59 ][ 8 ][ 9 ]]
|
||||
[[ char*->unsigned short ][ !!! *3* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ char*->unsigned long int ][ !!! *3* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ char*->unsigned long long ][ !!! *3* !!! ][ 59 ][ 10 ][ 8 ]]
|
||||
[[ char*->float ][ 48 ][ 80 ][ 32 ][ !!! *25* !!! ]]
|
||||
[[ char*->double ][ 48 ][ 81 ][ 32 ][ !!! *22* !!! ]]
|
||||
[[ char*->long double ][ 48 ][ 90 ][ 31 ][ !!! *22* !!! ]]
|
||||
[[ char*->array<char, 50> ][ !!! *<1* !!! ][ 59 ][ 9 ][ 7 ]]
|
||||
[[ char*->string ][ !!! *4* !!! ][ 77 ][ 15 ][ --- ]]
|
||||
[[ char*->container::string ][ !!! *1* !!! ][ 62 ][ 12 ][ --- ]]
|
||||
[[ unsigned char*->char ][ !!! *<1* !!! ][ 54 ][ 4 ][ 5 ]]
|
||||
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 53 ][ 4 ][ 5 ]]
|
||||
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 57 ][ 4 ][ 5 ]]
|
||||
[[ unsigned char*->int ][ !!! *3* !!! ][ 63 ][ 24 ][ 24 ]]
|
||||
[[ unsigned char*->short ][ !!! *5* !!! ][ 65 ][ 9 ][ 9 ]]
|
||||
[[ unsigned char*->long int ][ !!! *3* !!! ][ 60 ][ 10 ][ 8 ]]
|
||||
[[ unsigned char*->long long ][ !!! *4* !!! ][ 67 ][ 23 ][ 23 ]]
|
||||
[[ unsigned char*->unsigned int ][ !!! *5* !!! ][ 116 ][ 23 ][ 22 ]]
|
||||
[[ unsigned char*->unsigned short ][ !!! *5* !!! ][ 114 ][ 22 ][ 22 ]]
|
||||
[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 118 ][ 23 ][ 22 ]]
|
||||
[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 116 ][ 23 ][ 22 ]]
|
||||
[[ unsigned char*->float ][ 93 ][ 160 ][ 66 ][ !!! *47* !!! ]]
|
||||
[[ unsigned char*->double ][ 93 ][ 158 ][ 64 ][ !!! *46* !!! ]]
|
||||
[[ unsigned char*->long double ][ 93 ][ 158 ][ 64 ][ !!! *46* !!! ]]
|
||||
[[ unsigned char*->array<char, 50> ][ !!! *<1* !!! ][ 112 ][ 21 ][ 17 ]]
|
||||
[[ unsigned char*->string ][ !!! *10* !!! ][ 136 ][ 33 ][ --- ]]
|
||||
[[ unsigned char*->container::string ][ !!! *<1* !!! ][ 117 ][ 26 ][ --- ]]
|
||||
[[ signed char*->char ][ !!! *<1* !!! ][ 102 ][ 11 ][ 10 ]]
|
||||
[[ signed char*->signed char ][ !!! *<1* !!! ][ 102 ][ 11 ][ 12 ]]
|
||||
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 102 ][ 11 ][ 12 ]]
|
||||
[[ signed char*->int ][ !!! *5* !!! ][ 119 ][ 23 ][ 22 ]]
|
||||
[[ signed char*->short ][ !!! *5* !!! ][ 116 ][ 23 ][ 22 ]]
|
||||
[[ signed char*->long int ][ !!! *6* !!! ][ 116 ][ 23 ][ 22 ]]
|
||||
[[ signed char*->long long ][ !!! *6* !!! ][ 115 ][ 23 ][ 22 ]]
|
||||
[[ signed char*->unsigned int ][ !!! *5* !!! ][ 116 ][ 23 ][ 22 ]]
|
||||
[[ signed char*->unsigned short ][ !!! *5* !!! ][ 114 ][ 22 ][ 22 ]]
|
||||
[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 92 ][ 9 ][ 8 ]]
|
||||
[[ signed char*->unsigned long long ][ !!! *3* !!! ][ 60 ][ 9 ][ 10 ]]
|
||||
[[ signed char*->float ][ 94 ][ 134 ][ 51 ][ !!! *28* !!! ]]
|
||||
[[ signed char*->double ][ 47 ][ 80 ][ 31 ][ !!! *22* !!! ]]
|
||||
[[ signed char*->long double ][ 90 ][ 115 ][ 64 ][ !!! *25* !!! ]]
|
||||
[[ signed char*->array<char, 50> ][ !!! *<1* !!! ][ 97 ][ 22 ][ 17 ]]
|
||||
[[ signed char*->string ][ !!! *11* !!! ][ 139 ][ 34 ][ --- ]]
|
||||
[[ signed char*->container::string ][ !!! *<1* !!! ][ 118 ][ 26 ][ --- ]]
|
||||
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 106 ][ 15 ][ 10 ]]
|
||||
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 107 ][ 15 ][ 13 ]]
|
||||
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 107 ][ 15 ][ 12 ]]
|
||||
[[ iterator_range<char*>->int ][ !!! *5* !!! ][ 117 ][ 25 ][ 22 ]]
|
||||
[[ iterator_range<char*>->short ][ !!! *5* !!! ][ 116 ][ 25 ][ 22 ]]
|
||||
[[ iterator_range<char*>->long int ][ !!! *6* !!! ][ 114 ][ 22 ][ 20 ]]
|
||||
[[ iterator_range<char*>->long long ][ !!! *5* !!! ][ 106 ][ 23 ][ 22 ]]
|
||||
[[ iterator_range<char*>->unsigned int ][ !!! *5* !!! ][ 104 ][ 21 ][ 20 ]]
|
||||
[[ iterator_range<char*>->unsigned short ][ !!! *5* !!! ][ 105 ][ 22 ][ 20 ]]
|
||||
[[ iterator_range<char*>->unsigned long int ][ !!! *5* !!! ][ 106 ][ 22 ][ 20 ]]
|
||||
[[ iterator_range<char*>->unsigned long long ][ !!! *5* !!! ][ 105 ][ 23 ][ 20 ]]
|
||||
[[ iterator_range<char*>->float ][ 89 ][ 140 ][ !!! *42* !!! ][ 43 ]]
|
||||
[[ iterator_range<char*>->double ][ 88 ][ 127 ][ 43 ][ !!! *43* !!! ]]
|
||||
[[ iterator_range<char*>->long double ][ 88 ][ 127 ][ 43 ][ !!! *43* !!! ]]
|
||||
[[ iterator_range<char*>->array<char, 50> ][ !!! *<1* !!! ][ 104 ][ 22 ][ 15 ]]
|
||||
[[ iterator_range<char*>->string ][ !!! *9* !!! ][ 122 ][ 32 ][ --- ]]
|
||||
[[ iterator_range<char*>->container::string ][ !!! *<1* !!! ][ 105 ][ 24 ][ --- ]]
|
||||
[[ array<char, 50>->char ][ !!! *<1* !!! ][ 68 ][ 4 ][ 4 ]]
|
||||
[[ array<char, 50>->signed char ][ !!! *<1* !!! ][ 47 ][ 4 ][ 5 ]]
|
||||
[[ array<char, 50>->unsigned char ][ !!! *<1* !!! ][ 48 ][ 4 ][ 5 ]]
|
||||
[[ array<char, 50>->int ][ !!! *3* !!! ][ 53 ][ 9 ][ 8 ]]
|
||||
[[ array<char, 50>->short ][ !!! *3* !!! ][ 54 ][ 9 ][ 8 ]]
|
||||
[[ array<char, 50>->long int ][ !!! *3* !!! ][ 54 ][ 8 ][ 7 ]]
|
||||
[[ array<char, 50>->long long ][ !!! *3* !!! ][ 53 ][ 8 ][ 8 ]]
|
||||
[[ array<char, 50>->unsigned int ][ !!! *3* !!! ][ 52 ][ 7 ][ 8 ]]
|
||||
[[ array<char, 50>->unsigned short ][ !!! *3* !!! ][ 53 ][ 8 ][ 7 ]]
|
||||
[[ array<char, 50>->unsigned long int ][ !!! *3* !!! ][ 53 ][ 8 ][ 8 ]]
|
||||
[[ array<char, 50>->unsigned long long ][ !!! *3* !!! ][ 53 ][ 9 ][ 8 ]]
|
||||
[[ array<char, 50>->float ][ 43 ][ 72 ][ 29 ][ !!! *20* !!! ]]
|
||||
[[ array<char, 50>->double ][ 42 ][ 72 ][ 28 ][ !!! *20* !!! ]]
|
||||
[[ array<char, 50>->long double ][ 43 ][ 72 ][ 28 ][ !!! *20* !!! ]]
|
||||
[[ array<char, 50>->array<char, 50> ][ !!! *<1* !!! ][ 53 ][ 8 ][ 6 ]]
|
||||
[[ array<char, 50>->string ][ !!! *4* !!! ][ 62 ][ 13 ][ --- ]]
|
||||
[[ array<char, 50>->container::string ][ !!! *1* !!! ][ 54 ][ 10 ][ --- ]]
|
||||
[[ int->int ][ !!! *<1* !!! ][ 57 ][ 10 ][ --- ]]
|
||||
[[ float->double ][ !!! *<1* !!! ][ 102 ][ 49 ][ --- ]]
|
||||
[[ char->signed char ][ !!! *<1* !!! ][ 49 ][ 3 ][ --- ]]
|
||||
]
|
||||
[endsect]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2013-2023.
|
||||
// Copyright Antony Polukhin, 2013-2026.
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See the accompanying file LICENSE_1_0.txt
|
||||
@@ -7,9 +7,10 @@
|
||||
//[lexical_cast_args_example
|
||||
//`The following example treats command line arguments as a sequence of numeric data
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
int main(int /*argc*/, char * argv[])
|
||||
{
|
||||
using boost::lexical_cast;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2013-2023.
|
||||
// Copyright Antony Polukhin, 2013-2026.
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See the accompanying file LICENSE_1_0.txt
|
||||
@@ -14,12 +14,18 @@
|
||||
In this example we'll make a `stringize` method that accepts a sequence, converts
|
||||
each element of the sequence into string and appends that string to the result.
|
||||
|
||||
Example is based on the example from the [@http://www.packtpub.com/boost-cplusplus-application-development-cookbook/book Boost C++ Application Development Cookbook]
|
||||
Example is based on the example from the Boost C++ Application Development Cookbook
|
||||
by Antony Polukhin, ISBN 9781849514880. Russian translation: [@https://dmkpress.com/catalog/computer/programming/c/978-5-97060-868-5/ ISBN: 9785970608685].
|
||||
|
||||
Step 1: Making a functor that converts any type to a string and remembers result:
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/fusion/include/for_each.hpp>
|
||||
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||
#include <boost/fusion/adapted/std_pair.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
struct stringize_functor {
|
||||
@@ -38,7 +44,6 @@ public:
|
||||
};
|
||||
|
||||
//` Step 2: Applying `stringize_functor` to each element in sequence:
|
||||
#include <boost/fusion/include/for_each.hpp>
|
||||
template <class Sequence>
|
||||
std::string stringize(const Sequence& seq) {
|
||||
std::string result;
|
||||
@@ -47,9 +52,6 @@ std::string stringize(const Sequence& seq) {
|
||||
}
|
||||
|
||||
//` Step 3: Using the `stringize` with different types:
|
||||
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||
#include <boost/fusion/adapted/std_pair.hpp>
|
||||
|
||||
int main() {
|
||||
std::tuple<char, int, char, int> decim('-', 10, 'e', 5);
|
||||
if (stringize(decim) != "-10e5") {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// Copyright Antony Polukhin, 2013-2023.
|
||||
// Copyright Antony Polukhin, 2013-2026.
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See the accompanying file LICENSE_1_0.txt
|
||||
// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(disable: 4996) // `strerror` is not safe
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2013-2023.
|
||||
// Copyright Antony Polukhin, 2013-2026.
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See the accompanying file LICENSE_1_0.txt
|
||||
@@ -10,9 +10,13 @@
|
||||
In this example we'll make a `to_long_double` method that converts value of the Boost.Variant to `long double`.
|
||||
*/
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#ifdef BOOST_USE_MODULES
|
||||
#include <compare>
|
||||
#endif
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
struct to_long_double_functor: boost::static_visitor<long double> {
|
||||
template <class T>
|
||||
long double operator()(const T& v) const {
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <streambuf>
|
||||
|
||||
namespace boost { namespace detail {
|
||||
@@ -71,7 +72,7 @@ template<class charT, class BufferT>
|
||||
typename basic_pointerbuf<charT, BufferT>::pos_type
|
||||
basic_pointerbuf<charT, BufferT>::seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which)
|
||||
{
|
||||
typedef typename boost::int_t<sizeof(way) * CHAR_BIT>::least cast_type;
|
||||
typedef ::std::ios_base::seekdir cast_type;
|
||||
|
||||
if(which & ::std::ios_base::out)
|
||||
return pos_type(off_type(-1));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,10 +18,16 @@
|
||||
#ifndef BOOST_LEXICAL_CAST_INCLUDED
|
||||
#define BOOST_LEXICAL_CAST_INCLUDED
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
|
||||
#define BOOST_LCAST_NO_WCHAR_T
|
||||
@@ -34,6 +40,7 @@
|
||||
|
||||
namespace boost
|
||||
{
|
||||
BOOST_LEXICAL_CAST_BEGIN_MODULE_EXPORT
|
||||
template <typename Target, typename Source>
|
||||
inline Target lexical_cast(const Source &arg)
|
||||
{
|
||||
@@ -94,9 +101,12 @@ namespace boost
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_LEXICAL_CAST_END_MODULE_EXPORT
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_LCAST_NO_WCHAR_T
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_INCLUDED
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,6 +18,11 @@
|
||||
#ifndef BOOST_LEXICAL_CAST_BAD_LEXICAL_CAST_HPP
|
||||
#define BOOST_LEXICAL_CAST_BAD_LEXICAL_CAST_HPP
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
@@ -26,9 +31,11 @@
|
||||
#include <exception>
|
||||
#include <typeinfo>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
BOOST_LEXICAL_CAST_BEGIN_MODULE_EXPORT
|
||||
// exception used to indicate runtime lexical_cast failure
|
||||
class BOOST_SYMBOL_VISIBLE bad_lexical_cast :
|
||||
// workaround MSVC bug with std::bad_cast when _HAS_EXCEPTIONS == 0
|
||||
@@ -80,6 +87,7 @@ namespace boost
|
||||
const type_info_t *target;
|
||||
#endif
|
||||
};
|
||||
BOOST_LEXICAL_CAST_END_MODULE_EXPORT
|
||||
|
||||
namespace conversion { namespace detail {
|
||||
#ifdef BOOST_NO_TYPEID
|
||||
@@ -97,4 +105,6 @@ namespace boost
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_BAD_LEXICAL_CAST_HPP
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -7,12 +7,18 @@
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_BUFFER_VIEW_HPP
|
||||
#define BOOST_LEXICAL_CAST_DETAIL_BUFFER_VIEW_HPP
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <iosfwd>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace conversion { namespace detail {
|
||||
|
||||
@@ -55,5 +61,7 @@ namespace boost { namespace conversion { namespace detail {
|
||||
|
||||
}}} // namespace boost::conversion::detail
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_DETAIL_BUFFER_VIEW_HPP
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright Antony Polukhin, 2021-2026.
|
||||
//
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_CONFIG_HPP
|
||||
#define BOOST_LEXICAL_CAST_DETAIL_CONFIG_HPP
|
||||
|
||||
#ifdef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
# define BOOST_LEXICAL_CAST_BEGIN_MODULE_EXPORT export {
|
||||
# define BOOST_LEXICAL_CAST_END_MODULE_EXPORT }
|
||||
#else
|
||||
# define BOOST_LEXICAL_CAST_BEGIN_MODULE_EXPORT
|
||||
# define BOOST_LEXICAL_CAST_END_MODULE_EXPORT
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_USE_MODULES) && !defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
import boost.lexical_cast;
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_LEXICAL_CAST_DETAIL_CONFIG_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,6 +18,11 @@
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_HPP
|
||||
#define BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_HPP
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
@@ -27,26 +32,26 @@
|
||||
#define BOOST_LCAST_NO_WCHAR_T
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/type_traits/type_identity.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_float.hpp>
|
||||
#include <boost/type_traits/has_left_shift.hpp>
|
||||
#include <boost/type_traits/has_right_shift.hpp>
|
||||
#include <boost/detail/lcast_precision.hpp>
|
||||
|
||||
#include <boost/lexical_cast/detail/widest_char.hpp>
|
||||
#include <boost/lexical_cast/detail/is_character.hpp>
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <boost/lexical_cast/detail/buffer_view.hpp>
|
||||
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
#include <boost/container/container_fwd.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
|
||||
#include <boost/lexical_cast/detail/lcast_precision.hpp>
|
||||
#include <boost/lexical_cast/detail/widest_char.hpp>
|
||||
#include <boost/lexical_cast/detail/is_character.hpp>
|
||||
#include <boost/lexical_cast/detail/buffer_view.hpp>
|
||||
#include <boost/lexical_cast/detail/converter_lexical_streams.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -57,25 +62,28 @@ namespace boost {
|
||||
template<class IteratorT>
|
||||
class iterator_range;
|
||||
|
||||
// Forward declaration of boost::basic_string_view from Utility
|
||||
template<class Ch, class Tr> class basic_string_view;
|
||||
|
||||
namespace detail // normalize_single_byte_char<Char>
|
||||
{
|
||||
// Converts signed/unsigned char to char
|
||||
template < class Char >
|
||||
struct normalize_single_byte_char
|
||||
{
|
||||
typedef Char type;
|
||||
using type = Char;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct normalize_single_byte_char< signed char >
|
||||
{
|
||||
typedef char type;
|
||||
using type = char;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct normalize_single_byte_char< unsigned char >
|
||||
{
|
||||
typedef char type;
|
||||
using type = char;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -92,21 +100,21 @@ namespace boost {
|
||||
// Returns one of char, wchar_t, char16_t, char32_t or deduce_character_type_later<T> types
|
||||
// Executed on Stage 1 (See deduce_source_char<T> and deduce_target_char<T>)
|
||||
template < typename Type >
|
||||
struct stream_char_common: public boost::conditional<
|
||||
struct stream_char_common: public std::conditional<
|
||||
boost::detail::is_character< Type >::value,
|
||||
Type,
|
||||
boost::detail::deduce_character_type_later< Type >
|
||||
> {};
|
||||
|
||||
template < typename Char >
|
||||
struct stream_char_common< Char* >: public boost::conditional<
|
||||
struct stream_char_common< Char* >: public std::conditional<
|
||||
boost::detail::is_character< Char >::value,
|
||||
Char,
|
||||
boost::detail::deduce_character_type_later< Char* >
|
||||
> {};
|
||||
|
||||
template < typename Char >
|
||||
struct stream_char_common< const Char* >: public boost::conditional<
|
||||
struct stream_char_common< const Char* >: public std::conditional<
|
||||
boost::detail::is_character< Char >::value,
|
||||
Char,
|
||||
boost::detail::deduce_character_type_later< const Char* >
|
||||
@@ -115,18 +123,18 @@ namespace boost {
|
||||
template < typename Char >
|
||||
struct stream_char_common< boost::conversion::detail::buffer_view< Char > >
|
||||
{
|
||||
typedef Char type;
|
||||
using type = Char;
|
||||
};
|
||||
|
||||
template < typename Char >
|
||||
struct stream_char_common< boost::iterator_range< Char* > >: public boost::conditional<
|
||||
struct stream_char_common< boost::iterator_range< Char* > >: public std::conditional<
|
||||
boost::detail::is_character< Char >::value,
|
||||
Char,
|
||||
boost::detail::deduce_character_type_later< boost::iterator_range< Char* > >
|
||||
> {};
|
||||
|
||||
template < typename Char >
|
||||
struct stream_char_common< boost::iterator_range< const Char* > >: public boost::conditional<
|
||||
struct stream_char_common< boost::iterator_range< const Char* > >: public std::conditional<
|
||||
boost::detail::is_character< Char >::value,
|
||||
Char,
|
||||
boost::detail::deduce_character_type_later< boost::iterator_range< const Char* > >
|
||||
@@ -135,24 +143,24 @@ namespace boost {
|
||||
template < class Char, class Traits, class Alloc >
|
||||
struct stream_char_common< std::basic_string< Char, Traits, Alloc > >
|
||||
{
|
||||
typedef Char type;
|
||||
using type = Char;
|
||||
};
|
||||
|
||||
template < class Char, class Traits, class Alloc >
|
||||
struct stream_char_common< boost::container::basic_string< Char, Traits, Alloc > >
|
||||
{
|
||||
typedef Char type;
|
||||
using type = Char;
|
||||
};
|
||||
|
||||
template < typename Char, std::size_t N >
|
||||
struct stream_char_common< boost::array< Char, N > >: public boost::conditional<
|
||||
struct stream_char_common< boost::array< Char, N > >: public std::conditional<
|
||||
boost::detail::is_character< Char >::value,
|
||||
Char,
|
||||
boost::detail::deduce_character_type_later< boost::array< Char, N > >
|
||||
> {};
|
||||
|
||||
template < typename Char, std::size_t N >
|
||||
struct stream_char_common< boost::array< const Char, N > >: public boost::conditional<
|
||||
struct stream_char_common< boost::array< const Char, N > >: public std::conditional<
|
||||
boost::detail::is_character< Char >::value,
|
||||
Char,
|
||||
boost::detail::deduce_character_type_later< boost::array< const Char, N > >
|
||||
@@ -160,30 +168,49 @@ namespace boost {
|
||||
|
||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
||||
template < typename Char, std::size_t N >
|
||||
struct stream_char_common< std::array<Char, N > >: public boost::conditional<
|
||||
struct stream_char_common< std::array<Char, N > >: public std::conditional<
|
||||
boost::detail::is_character< Char >::value,
|
||||
Char,
|
||||
boost::detail::deduce_character_type_later< std::array< Char, N > >
|
||||
> {};
|
||||
|
||||
template < typename Char, std::size_t N >
|
||||
struct stream_char_common< std::array< const Char, N > >: public boost::conditional<
|
||||
struct stream_char_common< std::array< const Char, N > >: public std::conditional<
|
||||
boost::detail::is_character< Char >::value,
|
||||
Char,
|
||||
boost::detail::deduce_character_type_later< std::array< const Char, N > >
|
||||
> {};
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
|
||||
template < class Char, class Traits >
|
||||
struct stream_char_common< std::basic_string_view< Char, Traits > >
|
||||
{
|
||||
using type = Char;
|
||||
};
|
||||
#endif
|
||||
template < class Char, class Traits >
|
||||
struct stream_char_common< boost::basic_string_view< Char, Traits > >
|
||||
{
|
||||
using type = Char;
|
||||
};
|
||||
|
||||
#ifdef BOOST_HAS_INT128
|
||||
template <> struct stream_char_common< boost::int128_type >: public boost::type_identity< char > {};
|
||||
template <> struct stream_char_common< boost::uint128_type >: public boost::type_identity< char > {};
|
||||
template <> struct stream_char_common< boost::int128_type >
|
||||
{
|
||||
using type = char;
|
||||
};
|
||||
template <> struct stream_char_common< boost::uint128_type >
|
||||
{
|
||||
using type = char;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_LCAST_NO_WCHAR_T) && defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
||||
template <>
|
||||
struct stream_char_common< wchar_t >
|
||||
{
|
||||
typedef char type;
|
||||
using type = char;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
@@ -191,7 +218,7 @@ namespace boost {
|
||||
namespace detail // deduce_source_char_impl<T>
|
||||
{
|
||||
// If type T is `deduce_character_type_later` type, then tries to deduce
|
||||
// character type using boost::has_left_shift<T> metafunction.
|
||||
// character type using streaming metafunctions.
|
||||
// Otherwise supplied type T is a character type, that must be normalized
|
||||
// using normalize_single_byte_char<Char>.
|
||||
// Executed at Stage 2 (See deduce_source_char<T> and deduce_target_char<T>)
|
||||
@@ -204,20 +231,29 @@ namespace boost {
|
||||
template < class T >
|
||||
struct deduce_source_char_impl< deduce_character_type_later< T > >
|
||||
{
|
||||
typedef boost::has_left_shift< std::basic_ostream< char >, T > result_t;
|
||||
template <class U>
|
||||
static auto left_shift_type(long)
|
||||
-> decltype( std::declval<std::basic_ostream< char >&>() << std::declval<const U&>(), char{});
|
||||
|
||||
#if defined(BOOST_LCAST_NO_WCHAR_T)
|
||||
static_assert(result_t::value,
|
||||
"Source type is not std::ostream`able and std::wostream`s are not supported by your STL implementation");
|
||||
typedef char type;
|
||||
#else
|
||||
typedef typename boost::conditional<
|
||||
result_t::value, char, wchar_t
|
||||
>::type type;
|
||||
|
||||
static_assert(result_t::value || boost::has_left_shift< std::basic_ostream< type >, T >::value,
|
||||
"Source type is neither std::ostream`able nor std::wostream`able");
|
||||
#if !defined(BOOST_LCAST_NO_WCHAR_T)
|
||||
template <class U>
|
||||
static auto left_shift_type(int)
|
||||
-> decltype( std::declval<std::basic_ostream< wchar_t >&>() << std::declval<const U&>(), wchar_t{});
|
||||
#endif
|
||||
|
||||
template <class U>
|
||||
static void left_shift_type(...);
|
||||
|
||||
using type = decltype(left_shift_type<T>(1L));
|
||||
|
||||
static_assert(!std::is_same<type, void>::value,
|
||||
#if defined(BOOST_LCAST_NO_WCHAR_T)
|
||||
"Source type is not std::ostream`able and std::wostream`s are "
|
||||
"not supported by your STL implementation"
|
||||
#else
|
||||
"Source type is neither std::ostream`able nor std::wostream`able"
|
||||
#endif
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -237,20 +273,29 @@ namespace boost {
|
||||
template < class T >
|
||||
struct deduce_target_char_impl< deduce_character_type_later<T> >
|
||||
{
|
||||
typedef boost::has_right_shift<std::basic_istream<char>, T > result_t;
|
||||
template <class U>
|
||||
static auto right_shift_type(long)
|
||||
-> decltype( std::declval<std::basic_istream< char >&>() >> std::declval<U&>(), char{});
|
||||
|
||||
#if defined(BOOST_LCAST_NO_WCHAR_T)
|
||||
static_assert(result_t::value,
|
||||
"Target type is not std::istream`able and std::wistream`s are not supported by your STL implementation");
|
||||
typedef char type;
|
||||
#else
|
||||
typedef typename boost::conditional<
|
||||
result_t::value, char, wchar_t
|
||||
>::type type;
|
||||
|
||||
static_assert(result_t::value || boost::has_right_shift<std::basic_istream<wchar_t>, T >::value,
|
||||
"Target type is neither std::istream`able nor std::wistream`able");
|
||||
#if !defined(BOOST_LCAST_NO_WCHAR_T)
|
||||
template <class U>
|
||||
static auto right_shift_type(int)
|
||||
-> decltype( std::declval<std::basic_istream< wchar_t >&>() >> std::declval<U&>(), wchar_t{});
|
||||
#endif
|
||||
|
||||
template <class U>
|
||||
static void right_shift_type(...);
|
||||
|
||||
using type = decltype(right_shift_type<T>(1L));
|
||||
|
||||
static_assert(!std::is_same<type, void>::value,
|
||||
#if defined(BOOST_LCAST_NO_WCHAR_T)
|
||||
"Target type is not std::istream`able and std::wistream`s are "
|
||||
"not supported by your STL implementation"
|
||||
#else
|
||||
"Target type is neither std::istream`able nor std::wistream`able"
|
||||
#endif
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -275,44 +320,14 @@ namespace boost {
|
||||
struct deduce_target_char
|
||||
{
|
||||
typedef typename stream_char_common< T >::type stage1_type;
|
||||
typedef typename deduce_target_char_impl< stage1_type >::type stage2_type;
|
||||
|
||||
typedef stage2_type type;
|
||||
typedef typename deduce_target_char_impl< stage1_type >::type type;
|
||||
};
|
||||
|
||||
template < class T >
|
||||
struct deduce_source_char
|
||||
{
|
||||
typedef typename stream_char_common< T >::type stage1_type;
|
||||
typedef typename deduce_source_char_impl< stage1_type >::type stage2_type;
|
||||
|
||||
typedef stage2_type type;
|
||||
};
|
||||
}
|
||||
|
||||
namespace detail // extract_char_traits template
|
||||
{
|
||||
// We are attempting to get char_traits<> from T
|
||||
// template parameter. Otherwise we'll be using std::char_traits<Char>
|
||||
template < class Char, class T >
|
||||
struct extract_char_traits
|
||||
: boost::false_type
|
||||
{
|
||||
typedef std::char_traits< Char > trait_t;
|
||||
};
|
||||
|
||||
template < class Char, class Traits, class Alloc >
|
||||
struct extract_char_traits< Char, std::basic_string< Char, Traits, Alloc > >
|
||||
: boost::true_type
|
||||
{
|
||||
typedef Traits trait_t;
|
||||
};
|
||||
|
||||
template < class Char, class Traits, class Alloc>
|
||||
struct extract_char_traits< Char, boost::container::basic_string< Char, Traits, Alloc > >
|
||||
: boost::true_type
|
||||
{
|
||||
typedef Traits trait_t;
|
||||
typedef typename deduce_source_char_impl< stage1_type >::type type;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -357,19 +372,14 @@ namespace boost {
|
||||
// When is_specialized is false, the whole expression is 0.
|
||||
template <class Source>
|
||||
struct lcast_src_length<
|
||||
Source, typename boost::enable_if<boost::is_integral<Source> >::type
|
||||
Source, typename std::enable_if<boost::detail::lcast::is_integral<Source>::value >::type
|
||||
>
|
||||
{
|
||||
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value =
|
||||
std::numeric_limits<Source>::is_signed +
|
||||
std::numeric_limits<Source>::is_specialized + /* == 1 */
|
||||
std::numeric_limits<Source>::digits10 * 2
|
||||
);
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = 156);
|
||||
static_assert(sizeof(Source) * CHAR_BIT <= 256, "");
|
||||
#endif
|
||||
};
|
||||
|
||||
// Helper for floating point types.
|
||||
@@ -384,11 +394,9 @@ namespace boost {
|
||||
// sign + leading digit + decimal point + "e" + exponent sign == 5
|
||||
template<class Source>
|
||||
struct lcast_src_length<
|
||||
Source, typename boost::enable_if<boost::is_float<Source> >::type
|
||||
Source, typename std::enable_if<std::is_floating_point<Source>::value >::type
|
||||
>
|
||||
{
|
||||
|
||||
#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION
|
||||
static_assert(
|
||||
std::numeric_limits<Source>::max_exponent10 <= 999999L &&
|
||||
std::numeric_limits<Source>::min_exponent10 >= -999999L
|
||||
@@ -397,9 +405,6 @@ namespace boost {
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value =
|
||||
5 + lcast_precision<Source>::value + 6
|
||||
);
|
||||
#else // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION
|
||||
BOOST_STATIC_CONSTANT(std::size_t, value = 156);
|
||||
#endif // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION
|
||||
};
|
||||
}
|
||||
|
||||
@@ -408,7 +413,7 @@ namespace boost {
|
||||
template <class Source, class Target>
|
||||
struct lexical_cast_stream_traits {
|
||||
typedef typename boost::detail::array_to_pointer_decay<Source>::type src;
|
||||
typedef typename boost::remove_cv<src>::type no_cv_src;
|
||||
typedef typename std::remove_cv<src>::type no_cv_src;
|
||||
|
||||
typedef boost::detail::deduce_source_char<no_cv_src> deduce_src_char_metafunc;
|
||||
typedef typename deduce_src_char_metafunc::type src_char_t;
|
||||
@@ -419,43 +424,17 @@ namespace boost {
|
||||
>::type char_type;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T) && defined(BOOST_NO_CXX11_UNICODE_LITERALS)
|
||||
static_assert(!boost::is_same<char16_t, src_char_t>::value
|
||||
&& !boost::is_same<char16_t, target_char_t>::value,
|
||||
static_assert(!std::is_same<char16_t, src_char_t>::value
|
||||
&& !std::is_same<char16_t, target_char_t>::value,
|
||||
"Your compiler does not have full support for char16_t" );
|
||||
#endif
|
||||
#if !defined(BOOST_NO_CXX11_CHAR32_T) && defined(BOOST_NO_CXX11_UNICODE_LITERALS)
|
||||
static_assert(!boost::is_same<char32_t, src_char_t>::value
|
||||
&& !boost::is_same<char32_t, target_char_t>::value,
|
||||
static_assert(!std::is_same<char32_t, src_char_t>::value
|
||||
&& !std::is_same<char32_t, target_char_t>::value,
|
||||
"Your compiler does not have full support for char32_t" );
|
||||
#endif
|
||||
|
||||
typedef typename boost::conditional<
|
||||
boost::detail::extract_char_traits<char_type, Target>::value,
|
||||
typename boost::detail::extract_char_traits<char_type, Target>,
|
||||
typename boost::detail::extract_char_traits<char_type, no_cv_src>
|
||||
>::type::trait_t traits;
|
||||
|
||||
typedef boost::integral_constant<
|
||||
bool,
|
||||
boost::is_same<char, src_char_t>::value && // source is not a wide character based type
|
||||
(sizeof(char) != sizeof(target_char_t)) && // target type is based on wide character
|
||||
(!(boost::detail::is_character<no_cv_src>::value))
|
||||
> is_string_widening_required_t;
|
||||
|
||||
typedef boost::integral_constant<
|
||||
bool,
|
||||
!(boost::is_integral<no_cv_src>::value ||
|
||||
boost::detail::is_character<
|
||||
typename deduce_src_char_metafunc::stage1_type // if we did not get character type at stage1
|
||||
>::value // then we have no optimization for that type
|
||||
)
|
||||
> is_source_input_not_optimized_t;
|
||||
|
||||
// If we have an optimized conversion for
|
||||
// Source, we do not need to construct stringbuf.
|
||||
BOOST_STATIC_CONSTANT(bool, requires_stringbuf =
|
||||
(is_string_widening_required_t::value || is_source_input_not_optimized_t::value)
|
||||
);
|
||||
typedef std::char_traits<char_type> traits;
|
||||
|
||||
typedef boost::detail::lcast_src_length<no_cv_src> len_t;
|
||||
};
|
||||
@@ -468,29 +447,33 @@ namespace boost {
|
||||
{
|
||||
typedef lexical_cast_stream_traits<Source, Target> stream_trait;
|
||||
|
||||
typedef detail::lexical_istream_limited_src<
|
||||
typedef detail::lcast::optimized_src_stream<
|
||||
typename stream_trait::char_type,
|
||||
typename stream_trait::traits,
|
||||
stream_trait::requires_stringbuf,
|
||||
stream_trait::len_t::value + 1
|
||||
> i_interpreter_type;
|
||||
> optimized_src_stream;
|
||||
|
||||
template <class T>
|
||||
static auto detect_type(int)
|
||||
-> decltype(std::declval<optimized_src_stream&>().stream_in(std::declval<lcast::exact<T>>()), optimized_src_stream{});
|
||||
|
||||
typedef detail::lexical_ostream_limited_src<
|
||||
template <class T>
|
||||
static lcast::ios_src_stream<typename stream_trait::char_type, typename stream_trait::traits> detect_type(...);
|
||||
|
||||
using from_src_stream = decltype(detect_type<Source>(1));
|
||||
|
||||
typedef detail::lcast::to_target_stream<
|
||||
typename stream_trait::char_type,
|
||||
typename stream_trait::traits
|
||||
> o_interpreter_type;
|
||||
> to_target_stream;
|
||||
|
||||
static inline bool try_convert(const Source& arg, Target& result) {
|
||||
i_interpreter_type i_interpreter;
|
||||
|
||||
// Disabling ADL, by directly specifying operators.
|
||||
if (!(i_interpreter.operator <<(arg)))
|
||||
from_src_stream src_stream;
|
||||
if (!src_stream.stream_in(lcast::exact<Source>{arg}))
|
||||
return false;
|
||||
|
||||
o_interpreter_type out(i_interpreter.cbegin(), i_interpreter.cend());
|
||||
|
||||
// Disabling ADL, by directly specifying operators.
|
||||
if(!(out.operator >>(result)))
|
||||
to_target_stream out(src_stream.cbegin(), src_stream.cend());
|
||||
if (!out.stream_out(result))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -502,5 +485,7 @@ namespace boost {
|
||||
|
||||
#undef BOOST_LCAST_NO_WCHAR_T
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_HPP
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,125 +18,137 @@
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_CONVERTER_NUMERIC_HPP
|
||||
#define BOOST_LEXICAL_CAST_DETAIL_CONVERTER_NUMERIC_HPP
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <type_traits>
|
||||
#include <boost/core/cmath.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/type_traits/type_identity.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include <boost/type_traits/is_signed.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
#include <boost/type_traits/is_float.hpp>
|
||||
#include <boost/type_traits/remove_volatile.hpp>
|
||||
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
#endif // #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
|
||||
#include <boost/lexical_cast/detail/type_traits.hpp>
|
||||
|
||||
namespace boost { namespace detail {
|
||||
|
||||
template <class Source >
|
||||
struct detect_precision_loss
|
||||
{
|
||||
typedef Source source_type;
|
||||
typedef boost::numeric::Trunc<Source> Rounder;
|
||||
typedef typename conditional<
|
||||
boost::is_arithmetic<Source>::value, Source, Source const&
|
||||
>::type argument_type ;
|
||||
|
||||
static inline source_type nearbyint(argument_type s, bool& is_ok) noexcept {
|
||||
const source_type near_int = Rounder::nearbyint(s);
|
||||
if (near_int && is_ok) {
|
||||
const source_type orig_div_round = s / near_int;
|
||||
const source_type eps = std::numeric_limits<source_type>::epsilon();
|
||||
|
||||
is_ok = !((orig_div_round > 1 ? orig_div_round - 1 : 1 - orig_div_round) > eps);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
typedef typename Rounder::round_style round_style;
|
||||
};
|
||||
|
||||
template <typename Base, class Source>
|
||||
struct fake_precision_loss: public Base
|
||||
{
|
||||
typedef Source source_type ;
|
||||
typedef typename conditional<
|
||||
boost::is_arithmetic<Source>::value, Source, Source const&
|
||||
>::type argument_type ;
|
||||
|
||||
static inline source_type nearbyint(argument_type s, bool& /*is_ok*/) noexcept {
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
struct nothrow_overflow_handler
|
||||
{
|
||||
inline bool operator() ( boost::numeric::range_check_result r ) const noexcept {
|
||||
return (r == boost::numeric::cInRange);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Target, typename Source>
|
||||
inline bool noexcept_numeric_convert(const Source& arg, Target& result) noexcept {
|
||||
typedef boost::numeric::converter<
|
||||
Target,
|
||||
Source,
|
||||
boost::numeric::conversion_traits<Target, Source >,
|
||||
nothrow_overflow_handler,
|
||||
detect_precision_loss<Source >
|
||||
> converter_orig_t;
|
||||
|
||||
typedef typename boost::conditional<
|
||||
boost::is_base_of< detect_precision_loss<Source >, converter_orig_t >::value,
|
||||
converter_orig_t,
|
||||
fake_precision_loss<converter_orig_t, Source>
|
||||
>::type converter_t;
|
||||
|
||||
bool res = nothrow_overflow_handler()(converter_t::out_of_range(arg));
|
||||
if (res) {
|
||||
result = converter_t::low_level_convert(converter_t::nearbyint(arg, res));
|
||||
}
|
||||
|
||||
return res;
|
||||
template <class Source, class Target>
|
||||
bool ios_numeric_comparer_float(Source x, Source y) noexcept {
|
||||
return x == y
|
||||
|| (boost::core::isnan(x) && boost::core::isnan(y))
|
||||
|| (x < (std::numeric_limits<Target>::min)())
|
||||
;
|
||||
}
|
||||
|
||||
template <class RangeType, class T>
|
||||
constexpr bool is_out_of_range_for(T value) noexcept {
|
||||
return value > static_cast<T>((std::numeric_limits<RangeType>::max)())
|
||||
|| value < static_cast<T>((std::numeric_limits<RangeType>::min)())
|
||||
|| boost::core::isnan(value);
|
||||
}
|
||||
|
||||
|
||||
// integral -> integral
|
||||
template <typename Target, typename Source>
|
||||
typename std::enable_if<
|
||||
!std::is_floating_point<Source>::value && !std::is_floating_point<Target>::value, bool
|
||||
>::type noexcept_numeric_convert(Source arg, Target& result) noexcept {
|
||||
const Target target_tmp = static_cast<Target>(arg);
|
||||
const Source arg_restored = static_cast<Source>(target_tmp);
|
||||
if (arg == arg_restored) {
|
||||
result = target_tmp;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// integral -> floating point
|
||||
template <typename Target, typename Source>
|
||||
typename std::enable_if<
|
||||
!std::is_floating_point<Source>::value && std::is_floating_point<Target>::value, bool
|
||||
>::type noexcept_numeric_convert(Source arg, Target& result) noexcept {
|
||||
const Target target_tmp = static_cast<Target>(arg);
|
||||
result = target_tmp;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// floating point -> floating point
|
||||
template <typename Target, typename Source>
|
||||
typename std::enable_if<
|
||||
std::is_floating_point<Source>::value && std::is_floating_point<Target>::value, bool
|
||||
>::type noexcept_numeric_convert(Source arg, Target& result) noexcept {
|
||||
const Target target_tmp = static_cast<Target>(arg);
|
||||
const Source arg_restored = static_cast<Source>(target_tmp);
|
||||
if (detail::ios_numeric_comparer_float<Source, Target>(arg, arg_restored)) {
|
||||
result = target_tmp;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// floating point -> integral
|
||||
template <typename Target, typename Source>
|
||||
typename std::enable_if<
|
||||
std::is_floating_point<Source>::value && !std::is_floating_point<Target>::value, bool
|
||||
>::type noexcept_numeric_convert(Source arg, Target& result) noexcept {
|
||||
if (detail::is_out_of_range_for<Target>(arg)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const Target target_tmp = static_cast<Target>(arg);
|
||||
const Source arg_restored = static_cast<Source>(target_tmp);
|
||||
if (arg == arg_restored /* special values are handled in detail::is_out_of_range_for */) {
|
||||
result = target_tmp;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
struct lexical_cast_dynamic_num_not_ignoring_minus
|
||||
{
|
||||
static inline bool try_convert(const Source &arg, Target& result) noexcept {
|
||||
return noexcept_numeric_convert<Target, Source >(arg, result);
|
||||
template <typename Target, typename Source>
|
||||
static inline bool try_convert(Source arg, Target& result) noexcept {
|
||||
return boost::detail::noexcept_numeric_convert<Target, Source >(arg, result);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Target, typename Source>
|
||||
struct lexical_cast_dynamic_num_ignoring_minus
|
||||
{
|
||||
static inline bool try_convert(const Source &arg, Target& result) noexcept {
|
||||
typedef typename boost::conditional<
|
||||
boost::is_float<Source>::value,
|
||||
boost::type_identity<Source>,
|
||||
boost::make_unsigned<Source>
|
||||
template <typename Target, typename Source>
|
||||
#if defined(__clang__) && (__clang_major__ > 3 || __clang_minor__ > 6)
|
||||
__attribute__((no_sanitize("unsigned-integer-overflow")))
|
||||
#endif
|
||||
static inline bool try_convert(Source arg, Target& result) noexcept {
|
||||
typedef typename std::conditional<
|
||||
std::is_floating_point<Source>::value,
|
||||
std::conditional<true, Source, Source>, // std::type_identity emulation
|
||||
boost::detail::lcast::make_unsigned<Source>
|
||||
>::type usource_lazy_t;
|
||||
typedef typename usource_lazy_t::type usource_t;
|
||||
|
||||
if (arg < 0) {
|
||||
const bool res = noexcept_numeric_convert<Target, usource_t>(0u - arg, result);
|
||||
const bool res = boost::detail::noexcept_numeric_convert<Target, usource_t>(
|
||||
static_cast<usource_t>(0u - static_cast<usource_t>(arg)), result
|
||||
);
|
||||
result = static_cast<Target>(0u - result);
|
||||
return res;
|
||||
} else {
|
||||
return noexcept_numeric_convert<Target, usource_t>(arg, result);
|
||||
return boost::detail::noexcept_numeric_convert<Target, usource_t>(arg, result);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* lexical_cast_dynamic_num follows the rules:
|
||||
* dynamic_num_converter_impl follows the rules:
|
||||
* 1) If Source can be converted to Target without precision loss and
|
||||
* without overflows, then assign Source to Target and return
|
||||
*
|
||||
@@ -156,16 +168,14 @@ struct lexical_cast_dynamic_num_ignoring_minus
|
||||
template <typename Target, typename Source>
|
||||
struct dynamic_num_converter_impl
|
||||
{
|
||||
typedef typename boost::remove_volatile<Source>::type source_type;
|
||||
|
||||
static inline bool try_convert(source_type arg, Target& result) noexcept {
|
||||
typedef typename boost::conditional<
|
||||
boost::is_unsigned<Target>::value &&
|
||||
(boost::is_signed<source_type>::value || boost::is_float<source_type>::value) &&
|
||||
!(boost::is_same<source_type, bool>::value) &&
|
||||
!(boost::is_same<Target, bool>::value),
|
||||
lexical_cast_dynamic_num_ignoring_minus<Target, source_type>,
|
||||
lexical_cast_dynamic_num_not_ignoring_minus<Target, source_type>
|
||||
static inline bool try_convert(Source arg, Target& result) noexcept {
|
||||
typedef typename std::conditional<
|
||||
boost::detail::lcast::is_unsigned<Target>::value &&
|
||||
(boost::detail::lcast::is_signed<Source>::value || std::is_floating_point<Source>::value) &&
|
||||
!(std::is_same<Source, bool>::value) &&
|
||||
!(std::is_same<Target, bool>::value),
|
||||
lexical_cast_dynamic_num_ignoring_minus,
|
||||
lexical_cast_dynamic_num_not_ignoring_minus
|
||||
>::type caster_type;
|
||||
|
||||
return caster_type::try_convert(arg, result);
|
||||
@@ -174,5 +184,7 @@ struct dynamic_num_converter_impl
|
||||
|
||||
}} // namespace boost::detail
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_DETAIL_CONVERTER_NUMERIC_HPP
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,6 +18,11 @@
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_INF_NAN_HPP
|
||||
#define BOOST_LEXICAL_CAST_DETAIL_INF_NAN_HPP
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
@@ -28,10 +33,11 @@
|
||||
#endif
|
||||
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/core/cmath.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#endif // #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
|
||||
#include <boost/lexical_cast/detail/lcast_char_constants.hpp>
|
||||
|
||||
@@ -100,32 +106,25 @@ namespace boost {
|
||||
}
|
||||
|
||||
template <class CharT, class T>
|
||||
bool put_inf_nan_impl(CharT* begin, CharT*& end, const T& value
|
||||
const CharT* get_inf_nan_impl(T value
|
||||
, const CharT* lc_nan
|
||||
, const CharT* lc_infinity) noexcept
|
||||
, const CharT* lc_minus_nan
|
||||
, const CharT* lc_infinity
|
||||
, const CharT* lc_minus_infinity) noexcept
|
||||
{
|
||||
const CharT minus = lcast_char_constants<CharT>::minus;
|
||||
if (boost::core::isnan(value)) {
|
||||
if (boost::core::signbit(value)) {
|
||||
*begin = minus;
|
||||
++ begin;
|
||||
return lc_minus_nan;
|
||||
}
|
||||
|
||||
std::memcpy(begin, lc_nan, 3 * sizeof(CharT));
|
||||
end = begin + 3;
|
||||
return true;
|
||||
return lc_nan;
|
||||
} else if (boost::core::isinf(value)) {
|
||||
if (boost::core::signbit(value)) {
|
||||
*begin = minus;
|
||||
++ begin;
|
||||
return lc_minus_infinity;
|
||||
}
|
||||
|
||||
std::memcpy(begin, lc_infinity, 3 * sizeof(CharT));
|
||||
end = begin + 3;
|
||||
return true;
|
||||
return lc_infinity;
|
||||
}
|
||||
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,8 +138,8 @@ namespace boost {
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool put_inf_nan(wchar_t* begin, wchar_t*& end, const T& value) noexcept {
|
||||
return put_inf_nan_impl(begin, end, value, L"nan", L"infinity");
|
||||
const wchar_t* get_inf_nan(T value, wchar_t) noexcept {
|
||||
return detail::get_inf_nan_impl(value, L"nan", L"-nan", L"inf", L"-inf");
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -154,8 +153,8 @@ namespace boost {
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool put_inf_nan(char16_t* begin, char16_t*& end, const T& value) noexcept {
|
||||
return put_inf_nan_impl(begin, end, value, u"nan", u"infinity");
|
||||
const char16_t* get_inf_nan(T value, char16_t) noexcept {
|
||||
return detail::get_inf_nan_impl(value, u"nan", u"-nan", u"inf", u"-inf");
|
||||
}
|
||||
#endif
|
||||
#if !defined(BOOST_NO_CXX11_CHAR32_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
|
||||
@@ -168,8 +167,8 @@ namespace boost {
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool put_inf_nan(char32_t* begin, char32_t*& end, const T& value) noexcept {
|
||||
return put_inf_nan_impl(begin, end, value, U"nan", U"infinity");
|
||||
const char32_t* get_inf_nan(T value, char32_t) noexcept {
|
||||
return detail::get_inf_nan_impl(value, U"nan", U"-nan", U"inf", U"-inf");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -181,14 +180,16 @@ namespace boost {
|
||||
, '(', ')');
|
||||
}
|
||||
|
||||
template <class CharT, class T>
|
||||
bool put_inf_nan(CharT* begin, CharT*& end, const T& value) noexcept {
|
||||
return put_inf_nan_impl(begin, end, value, "nan", "infinity");
|
||||
template <class T>
|
||||
const char* get_inf_nan(T value, char) noexcept {
|
||||
return detail::get_inf_nan_impl(value, "nan", "-nan", "inf", "-inf");
|
||||
}
|
||||
}
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_LCAST_NO_WCHAR_T
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_DETAIL_INF_NAN_HPP
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,42 +18,43 @@
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_IS_CHARACTER_HPP
|
||||
#define BOOST_LEXICAL_CAST_DETAIL_IS_CHARACTER_HPP
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
#endif // #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
|
||||
namespace detail // is_character<...>
|
||||
{
|
||||
// returns true, if T is one of the character types
|
||||
template < typename T >
|
||||
struct is_character
|
||||
{
|
||||
typedef typename boost::integral_constant<
|
||||
bool,
|
||||
boost::is_same< T, char >::value ||
|
||||
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING)
|
||||
boost::is_same< T, wchar_t >::value ||
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_CHAR16_T
|
||||
boost::is_same< T, char16_t >::value ||
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_CHAR32_T
|
||||
boost::is_same< T, char32_t >::value ||
|
||||
#endif
|
||||
boost::is_same< T, unsigned char >::value ||
|
||||
boost::is_same< T, signed char >::value
|
||||
> type;
|
||||
namespace boost { namespace detail {
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, value = (type::value) );
|
||||
};
|
||||
}
|
||||
}
|
||||
// returns true, if T is one of the character types
|
||||
template < typename T >
|
||||
using is_character = std::integral_constant<
|
||||
bool,
|
||||
std::is_same< T, char >::value ||
|
||||
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING)
|
||||
std::is_same< T, wchar_t >::value ||
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_CHAR16_T
|
||||
std::is_same< T, char16_t >::value ||
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_CHAR32_T
|
||||
std::is_same< T, char32_t >::value ||
|
||||
#endif
|
||||
std::is_same< T, unsigned char >::value ||
|
||||
std::is_same< T, signed char >::value
|
||||
>;
|
||||
|
||||
}}
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_DETAIL_IS_CHARACTER_HPP
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_BASIC_UNLOCKEDBUF_HPP
|
||||
#define BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_BASIC_UNLOCKEDBUF_HPP
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BOOST_NO_STRINGSTREAM
|
||||
#include <strstream>
|
||||
#else
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include <boost/detail/basic_pointerbuf.hpp>
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
# include <cwchar>
|
||||
#endif
|
||||
#endif // #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
|
||||
namespace boost { namespace detail { namespace lcast {
|
||||
|
||||
// acts as a stream buffer which wraps around a pair of pointers
|
||||
// and gives acces to internals
|
||||
template <class BufferType, class CharT>
|
||||
class basic_unlockedbuf : public basic_pointerbuf<CharT, BufferType> {
|
||||
public:
|
||||
typedef basic_pointerbuf<CharT, BufferType> base_type;
|
||||
typedef typename base_type::streamsize streamsize;
|
||||
|
||||
using base_type::pptr;
|
||||
using base_type::pbase;
|
||||
using base_type::setbuf;
|
||||
};
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM)
|
||||
template <class CharT, class Traits>
|
||||
using out_stream_t = std::ostream;
|
||||
|
||||
template <class CharT, class Traits>
|
||||
using stringbuffer_t = basic_unlockedbuf<std::strstreambuf, char>;
|
||||
#elif defined(BOOST_NO_STD_LOCALE)
|
||||
template <class CharT, class Traits>
|
||||
using out_stream_t = std::ostream;
|
||||
|
||||
template <class CharT, class Traits>
|
||||
using stringbuffer_t = basic_unlockedbuf<std::stringbuf, char>;
|
||||
|
||||
template <class CharT, class Traits>
|
||||
using buffer_t = basic_unlockedbuf<std::streambuf, char>;
|
||||
#else
|
||||
template <class CharT, class Traits>
|
||||
using out_stream_t = std::basic_ostream<CharT, Traits>;
|
||||
|
||||
template <class CharT, class Traits>
|
||||
using stringbuffer_t = basic_unlockedbuf<std::basic_stringbuf<CharT, Traits>, CharT>;
|
||||
|
||||
template <class CharT, class Traits>
|
||||
using buffer_t = basic_unlockedbuf<std::basic_streambuf<CharT, Traits>, CharT>;
|
||||
#endif
|
||||
|
||||
}}} // namespace boost::detail::lcast
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_BASIC_UNLOCKEDBUF_HPP
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,10 +18,16 @@
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_LCAST_CHAR_CONSTANTS_HPP
|
||||
#define BOOST_LEXICAL_CAST_DETAIL_LCAST_CHAR_CONSTANTS_HPP
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
#endif // #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -41,6 +47,7 @@ namespace boost
|
||||
}
|
||||
} // namespace boost
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_DETAIL_LCAST_CHAR_CONSTANTS_HPP
|
||||
|
||||
|
||||
+32
-45
@@ -8,66 +8,58 @@
|
||||
#ifndef BOOST_DETAIL_LCAST_PRECISION_HPP_INCLUDED
|
||||
#define BOOST_DETAIL_LCAST_PRECISION_HPP_INCLUDED
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <climits>
|
||||
#include <ios>
|
||||
#include <limits>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/integer_traits.hpp>
|
||||
|
||||
#ifndef BOOST_NO_IS_ABSTRACT
|
||||
// Fix for SF:1358600 - lexical_cast & pure virtual functions & VC 8 STL
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_traits/is_abstract.hpp>
|
||||
#endif
|
||||
#endif // #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
|
||||
namespace boost { namespace detail {
|
||||
|
||||
class lcast_abstract_stub {};
|
||||
|
||||
// Calculate an argument to pass to std::ios_base::precision from
|
||||
// lexical_cast. See alternative implementation for broken standard
|
||||
// libraries in lcast_get_precision below. Keep them in sync, please.
|
||||
// lexical_cast.
|
||||
template<class T>
|
||||
struct lcast_precision
|
||||
{
|
||||
#ifdef BOOST_NO_IS_ABSTRACT
|
||||
typedef std::numeric_limits<T> limits; // No fix for SF:1358600.
|
||||
#else
|
||||
typedef typename boost::conditional<
|
||||
boost::is_abstract<T>::value
|
||||
, std::numeric_limits<lcast_abstract_stub>
|
||||
, std::numeric_limits<T>
|
||||
>::type limits;
|
||||
#endif
|
||||
using limits = std::numeric_limits<T>;
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, use_default_precision =
|
||||
static constexpr bool use_default_precision =
|
||||
!limits::is_specialized || limits::is_exact
|
||||
);
|
||||
;
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, is_specialized_bin =
|
||||
static constexpr bool is_specialized_bin =
|
||||
!use_default_precision &&
|
||||
limits::radix == 2 && limits::digits > 0
|
||||
);
|
||||
;
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, is_specialized_dec =
|
||||
static constexpr bool is_specialized_dec =
|
||||
!use_default_precision &&
|
||||
limits::radix == 10 && limits::digits10 > 0
|
||||
);
|
||||
;
|
||||
|
||||
BOOST_STATIC_CONSTANT(std::streamsize, streamsize_max =
|
||||
boost::integer_traits<std::streamsize>::const_max
|
||||
);
|
||||
static constexpr std::streamsize streamsize_max =
|
||||
(std::numeric_limits<std::streamsize>::max)()
|
||||
;
|
||||
|
||||
BOOST_STATIC_CONSTANT(unsigned int, precision_dec = limits::digits10 + 1U);
|
||||
static constexpr unsigned int precision_dec = limits::digits10 + 1U;
|
||||
|
||||
static_assert(!is_specialized_dec ||
|
||||
precision_dec <= streamsize_max + 0UL
|
||||
, "");
|
||||
|
||||
BOOST_STATIC_CONSTANT(unsigned long, precision_bin =
|
||||
static constexpr unsigned long precision_bin =
|
||||
2UL + limits::digits * 30103UL / 100000UL
|
||||
);
|
||||
;
|
||||
|
||||
static_assert(!is_specialized_bin ||
|
||||
(limits::digits + 0UL < ULONG_MAX / 30103UL &&
|
||||
@@ -75,34 +67,29 @@ struct lcast_precision
|
||||
precision_bin <= streamsize_max + 0UL)
|
||||
, "");
|
||||
|
||||
BOOST_STATIC_CONSTANT(std::streamsize, value =
|
||||
static constexpr std::streamsize value =
|
||||
is_specialized_bin ? precision_bin
|
||||
: is_specialized_dec ? precision_dec : 6
|
||||
);
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
inline std::streamsize lcast_get_precision(T* = 0)
|
||||
{
|
||||
return lcast_precision<T>::value;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void lcast_set_precision(std::ios_base& stream, T*)
|
||||
{
|
||||
stream.precision(lcast_get_precision<T>());
|
||||
stream.precision(lcast_precision<T>::value);
|
||||
}
|
||||
|
||||
template<class Source, class Target>
|
||||
inline void lcast_set_precision(std::ios_base& stream, Source*, Target*)
|
||||
{
|
||||
std::streamsize const s = lcast_get_precision(static_cast<Source*>(0));
|
||||
std::streamsize const t = lcast_get_precision(static_cast<Target*>(0));
|
||||
std::streamsize const s = lcast_precision<Source>::value;
|
||||
std::streamsize const t = lcast_precision<Target*>::value;
|
||||
stream.precision(s > t ? s : t);
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_DETAIL_LCAST_PRECISION_HPP_INCLUDED
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,6 +18,11 @@
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_LCAST_UNSIGNED_CONVERTERS_HPP
|
||||
#define BOOST_LEXICAL_CAST_DETAIL_LCAST_UNSIGNED_CONVERTERS_HPP
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
@@ -28,9 +33,10 @@
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <type_traits>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/lexical_cast/detail/type_traits.hpp>
|
||||
|
||||
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
@@ -47,18 +53,22 @@
|
||||
#endif
|
||||
|
||||
#include <boost/lexical_cast/detail/lcast_char_constants.hpp>
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include <boost/type_traits/is_signed.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#endif // #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
|
||||
#include <boost/lexical_cast/detail/lcast_char_constants.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace detail // lcast_to_unsigned
|
||||
{
|
||||
template<class T>
|
||||
#if defined(__clang__) && (__clang_major__ > 3 || __clang_minor__ > 6)
|
||||
__attribute__((no_sanitize("unsigned-integer-overflow")))
|
||||
#endif
|
||||
inline
|
||||
typename boost::make_unsigned<T>::type lcast_to_unsigned(const T value) noexcept {
|
||||
typedef typename boost::make_unsigned<T>::type result_type;
|
||||
typename boost::detail::lcast::make_unsigned<T>::type lcast_to_unsigned(const T value) noexcept {
|
||||
typedef typename boost::detail::lcast::make_unsigned<T>::type result_type;
|
||||
return value < 0
|
||||
? static_cast<result_type>(0u - static_cast<result_type>(value))
|
||||
: static_cast<result_type>(value);
|
||||
@@ -70,7 +80,7 @@ namespace boost
|
||||
template <class Traits, class T, class CharT>
|
||||
class lcast_put_unsigned: boost::noncopyable {
|
||||
typedef typename Traits::int_type int_type;
|
||||
typename boost::conditional<
|
||||
typename std::conditional<
|
||||
(sizeof(unsigned) > sizeof(T))
|
||||
, unsigned
|
||||
, T
|
||||
@@ -251,6 +261,9 @@ namespace boost
|
||||
private:
|
||||
// Iteration that does not care about grouping/separators and assumes that all
|
||||
// input characters are digits
|
||||
#if defined(__clang__) && (__clang_major__ > 3 || __clang_minor__ > 6)
|
||||
__attribute__((no_sanitize("unsigned-integer-overflow")))
|
||||
#endif
|
||||
inline bool main_convert_iteration() noexcept {
|
||||
CharT const czero = lcast_char_constants<CharT>::zero;
|
||||
T const maxv = (std::numeric_limits<T>::max)();
|
||||
@@ -289,5 +302,7 @@ namespace boost
|
||||
}
|
||||
} // namespace boost
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_DETAIL_LCAST_UNSIGNED_CONVERTERS_HPP
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
// Copyright Peter Dimov, 2025.
|
||||
// Copyright Romain Geissler, 2025.
|
||||
//
|
||||
// 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)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_TYPE_TRAITS_HPP
|
||||
#define BOOST_LEXICAL_CAST_DETAIL_TYPE_TRAITS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost { namespace detail { namespace lcast {
|
||||
|
||||
// libstdc++ from gcc <= 15 doesn't provide support for __int128 in the standard traits,
|
||||
// so define them explicitly.
|
||||
// This was fixed with gcc >= 16, so we may eventually remove this workaround and use
|
||||
// directly the standard type_traits.
|
||||
|
||||
template<class T> struct is_integral: public std::is_integral<T>
|
||||
{
|
||||
};
|
||||
|
||||
template<class T> struct is_signed: public std::is_signed<T>
|
||||
{
|
||||
};
|
||||
|
||||
template<class T> struct is_unsigned: public std::is_unsigned<T>
|
||||
{
|
||||
};
|
||||
|
||||
template<class T> struct make_unsigned: public std::make_unsigned<T>
|
||||
{
|
||||
};
|
||||
|
||||
#if defined(__SIZEOF_INT128__)
|
||||
|
||||
template<> struct is_integral<__int128_t>: public std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template<> struct is_integral<__uint128_t>: public std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template<> struct is_signed<__int128_t>: public std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template<> struct is_signed<__uint128_t>: public std::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template<> struct is_unsigned<__int128_t>: public std::false_type
|
||||
{
|
||||
};
|
||||
|
||||
template<> struct is_unsigned<__uint128_t>: public std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template<> struct make_unsigned<__int128_t>
|
||||
{
|
||||
typedef __uint128_t type;
|
||||
};
|
||||
|
||||
template<> struct make_unsigned<__uint128_t>
|
||||
{
|
||||
typedef __uint128_t type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}}} // namespace boost::detail::lcast
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_DETAIL_TYPE_TRAITS_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,26 +18,32 @@
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_WIDEST_CHAR_HPP
|
||||
#define BOOST_LEXICAL_CAST_DETAIL_WIDEST_CHAR_HPP
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#endif // #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
|
||||
namespace boost { namespace detail {
|
||||
|
||||
template <typename TargetChar, typename SourceChar>
|
||||
struct widest_char {
|
||||
typedef typename boost::conditional<
|
||||
(sizeof(TargetChar) > sizeof(SourceChar))
|
||||
, TargetChar
|
||||
, SourceChar
|
||||
>::type type;
|
||||
};
|
||||
template <typename TargetChar, typename SourceChar>
|
||||
using widest_char = std::conditional<
|
||||
(sizeof(TargetChar) > sizeof(SourceChar))
|
||||
, TargetChar
|
||||
, SourceChar
|
||||
>;
|
||||
|
||||
}} // namespace boost::detail
|
||||
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_DETAIL_WIDEST_CHAR_HPP
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,185 +18,58 @@
|
||||
#ifndef BOOST_LEXICAL_CAST_TRY_LEXICAL_CONVERT_HPP
|
||||
#define BOOST_LEXICAL_CAST_TRY_LEXICAL_CONVERT_HPP
|
||||
|
||||
#include <boost/lexical_cast/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) || (defined(__GNUC__) && \
|
||||
!(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && \
|
||||
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wuninitialized"
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/type_identity.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
|
||||
#include <boost/lexical_cast/detail/buffer_view.hpp>
|
||||
#include <boost/lexical_cast/detail/is_character.hpp>
|
||||
#include <boost/lexical_cast/detail/converter_numeric.hpp>
|
||||
#include <boost/lexical_cast/detail/converter_lexical.hpp>
|
||||
|
||||
#include <boost/container/container_fwd.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail
|
||||
{
|
||||
template<typename T>
|
||||
struct is_stdstring
|
||||
: boost::false_type
|
||||
{};
|
||||
|
||||
template<typename CharT, typename Traits, typename Alloc>
|
||||
struct is_stdstring< std::basic_string<CharT, Traits, Alloc> >
|
||||
: boost::true_type
|
||||
{};
|
||||
|
||||
// Sun Studio has problem with partial specialization of templates differing only in namespace.
|
||||
// We workaround that by making `is_booststring` trait, instead of specializing `is_stdstring` for `boost::container::basic_string`.
|
||||
template<typename T>
|
||||
struct is_booststring
|
||||
: boost::false_type
|
||||
{};
|
||||
|
||||
template<typename CharT, typename Traits, typename Alloc>
|
||||
struct is_booststring< boost::container::basic_string<CharT, Traits, Alloc> >
|
||||
: boost::true_type
|
||||
{};
|
||||
|
||||
template<typename Target, typename Source>
|
||||
struct is_arithmetic_and_not_xchars
|
||||
{
|
||||
typedef boost::integral_constant<
|
||||
bool,
|
||||
!(boost::detail::is_character<Target>::value) &&
|
||||
!(boost::detail::is_character<Source>::value) &&
|
||||
boost::is_arithmetic<Source>::value &&
|
||||
boost::is_arithmetic<Target>::value
|
||||
> type;
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, value = (
|
||||
type::value
|
||||
));
|
||||
};
|
||||
|
||||
/*
|
||||
* is_xchar_to_xchar<Target, Source>::value is true,
|
||||
* Target and Souce are char types of the same size 1 (char, signed char, unsigned char).
|
||||
*/
|
||||
template<typename Target, typename Source>
|
||||
struct is_xchar_to_xchar
|
||||
{
|
||||
typedef boost::integral_constant<
|
||||
bool,
|
||||
sizeof(Source) == sizeof(Target) &&
|
||||
sizeof(Source) == sizeof(char) &&
|
||||
boost::detail::is_character<Target>::value &&
|
||||
boost::detail::is_character<Source>::value
|
||||
> type;
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, value = (
|
||||
type::value
|
||||
));
|
||||
};
|
||||
|
||||
template<typename Target, typename Source>
|
||||
struct is_char_array_to_stdstring
|
||||
: boost::false_type
|
||||
{};
|
||||
|
||||
template<typename CharT, typename Traits, typename Alloc>
|
||||
struct is_char_array_to_stdstring< std::basic_string<CharT, Traits, Alloc>, CharT* >
|
||||
: boost::true_type
|
||||
{};
|
||||
|
||||
template<typename CharT, typename Traits, typename Alloc>
|
||||
struct is_char_array_to_stdstring< std::basic_string<CharT, Traits, Alloc>, const CharT* >
|
||||
: boost::true_type
|
||||
{};
|
||||
|
||||
// Sun Studio has problem with partial specialization of templates differing only in namespace.
|
||||
// We workaround that by making `is_char_array_to_booststring` trait, instead of specializing `is_char_array_to_stdstring` for `boost::container::basic_string`.
|
||||
template<typename Target, typename Source>
|
||||
struct is_char_array_to_booststring
|
||||
: boost::false_type
|
||||
{};
|
||||
|
||||
template<typename CharT, typename Traits, typename Alloc>
|
||||
struct is_char_array_to_booststring< boost::container::basic_string<CharT, Traits, Alloc>, CharT* >
|
||||
: boost::true_type
|
||||
{};
|
||||
|
||||
template<typename CharT, typename Traits, typename Alloc>
|
||||
struct is_char_array_to_booststring< boost::container::basic_string<CharT, Traits, Alloc>, const CharT* >
|
||||
: boost::true_type
|
||||
{};
|
||||
|
||||
template <typename Target, typename Source>
|
||||
struct copy_converter_impl
|
||||
{
|
||||
// MSVC fail to forward an array (DevDiv#555157 "SILENT BAD CODEGEN triggered by perfect forwarding",
|
||||
// fixed in 2013 RTM).
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && (!defined(BOOST_MSVC) || BOOST_MSVC >= 1800)
|
||||
template <class T>
|
||||
static inline bool try_convert(T&& arg, Target& result) {
|
||||
result = static_cast<T&&>(arg); // eqaul to `result = std::forward<T>(arg);`
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
static inline bool try_convert(const Source& arg, Target& result) {
|
||||
result = arg;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
using is_arithmetic_and_not_xchars = std::integral_constant<
|
||||
bool,
|
||||
!(boost::detail::is_character<Target>::value) &&
|
||||
!(boost::detail::is_character<Source>::value) &&
|
||||
std::is_arithmetic<Source>::value &&
|
||||
std::is_arithmetic<Target>::value
|
||||
>;
|
||||
}
|
||||
|
||||
namespace conversion { namespace detail {
|
||||
|
||||
BOOST_LEXICAL_CAST_BEGIN_MODULE_EXPORT
|
||||
|
||||
template <typename Target, typename Source>
|
||||
inline bool try_lexical_convert(const Source& arg, Target& result)
|
||||
{
|
||||
typedef typename boost::detail::array_to_pointer_decay<Source>::type src;
|
||||
static_assert(
|
||||
!std::is_volatile<Source>::value,
|
||||
"Boost.LexicalCast does not support volatile input");
|
||||
|
||||
typedef boost::integral_constant<
|
||||
bool,
|
||||
boost::detail::is_xchar_to_xchar<Target, src >::value ||
|
||||
boost::detail::is_char_array_to_stdstring<Target, src >::value ||
|
||||
boost::detail::is_char_array_to_booststring<Target, src >::value ||
|
||||
(
|
||||
boost::is_same<Target, src >::value &&
|
||||
(boost::detail::is_stdstring<Target >::value || boost::detail::is_booststring<Target >::value)
|
||||
) ||
|
||||
(
|
||||
boost::is_same<Target, src >::value &&
|
||||
boost::detail::is_character<Target >::value
|
||||
)
|
||||
> shall_we_copy_t;
|
||||
typedef typename boost::detail::array_to_pointer_decay<Source>::type src;
|
||||
|
||||
typedef boost::detail::is_arithmetic_and_not_xchars<Target, src >
|
||||
shall_we_copy_with_dynamic_check_t;
|
||||
|
||||
// We do evaluate second `if_` lazily to avoid unnecessary instantiations
|
||||
// of `shall_we_copy_with_dynamic_check_t` and improve compilation times.
|
||||
typedef typename boost::conditional<
|
||||
shall_we_copy_t::value,
|
||||
boost::type_identity<boost::detail::copy_converter_impl<Target, src > >,
|
||||
boost::conditional<
|
||||
shall_we_copy_with_dynamic_check_t::value,
|
||||
boost::detail::dynamic_num_converter_impl<Target, src >,
|
||||
boost::detail::lexical_converter_impl<Target, src >
|
||||
>
|
||||
>::type caster_type_lazy;
|
||||
|
||||
typedef typename caster_type_lazy::type caster_type;
|
||||
typedef typename std::conditional<
|
||||
shall_we_copy_with_dynamic_check_t::value,
|
||||
boost::detail::dynamic_num_converter_impl<Target, src >,
|
||||
boost::detail::lexical_converter_impl<Target, src >
|
||||
>::type caster_type;
|
||||
|
||||
return caster_type::try_convert(arg, result);
|
||||
}
|
||||
@@ -213,21 +86,20 @@ namespace boost {
|
||||
result
|
||||
);
|
||||
}
|
||||
BOOST_LEXICAL_CAST_END_MODULE_EXPORT
|
||||
|
||||
}} // namespace conversion::detail
|
||||
|
||||
namespace conversion {
|
||||
BOOST_LEXICAL_CAST_BEGIN_MODULE_EXPORT
|
||||
// ADL barrier
|
||||
using ::boost::conversion::detail::try_lexical_convert;
|
||||
BOOST_LEXICAL_CAST_END_MODULE_EXPORT
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if defined(__clang__) || (defined(__GNUC__) && \
|
||||
!(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) && \
|
||||
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT)
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_TRY_LEXICAL_CONVERT_HPP
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2016-2025 Antony Polukhin
|
||||
//
|
||||
// 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)
|
||||
|
||||
// To compile manually use a command like the folowing:
|
||||
// clang++ -I ../include -std=c++20 --precompile -x c++-module boost_lexical_cast.cppm
|
||||
|
||||
module;
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/container/container_fwd.hpp>
|
||||
#include <boost/core/cmath.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#include <boost/core/snprintf.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <boost/detail/basic_pointerbuf.hpp>
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_USE_STD_MODULE
|
||||
#include <array>
|
||||
#include <climits>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
# include <cwchar>
|
||||
#endif
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
#include <istream>
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
# include <locale>
|
||||
#endif
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <typeinfo>
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
#define BOOST_LEXICAL_CAST_INTERFACE_UNIT
|
||||
|
||||
export module boost.lexical_cast;
|
||||
|
||||
#ifdef BOOST_LEXICAL_CAST_USE_STD_MODULE
|
||||
import std;
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang diagnostic ignored "-Winclude-angled-in-module-purview"
|
||||
#endif
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2024-2025 Antony Polukhin
|
||||
//
|
||||
// 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)
|
||||
|
||||
// To compile manually use a command like the following:
|
||||
// clang++ -std=c++20 -fmodule-file=lexical_cast.pcm lexical_cast.pcm usage_sample.cpp
|
||||
|
||||
//[lexical_cast_module_example
|
||||
import boost.lexical_cast;
|
||||
|
||||
int main() {
|
||||
return boost::lexical_cast<int>("0");
|
||||
}
|
||||
//]
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#==============================================================================
|
||||
# Copyright (c) Antony Polukhin, 2012-2023.
|
||||
# Copyright Antony Polukhin, 2012-2026.
|
||||
#
|
||||
# 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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Antony Polukhin, 2012-2023.
|
||||
// (C) Copyright Antony Polukhin, 2012-2026.
|
||||
// Use, modification and distribution are subject to 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)
|
||||
@@ -14,10 +14,15 @@
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/chrono.hpp>
|
||||
#include <fstream>
|
||||
#include <cstring>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
#include <boost/container/string.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
// File to output data
|
||||
std::fstream fout;
|
||||
@@ -91,6 +96,12 @@ struct structure_sprintf {
|
||||
sprintf(buffer, conv, in_val.c_str());
|
||||
OutT out_val(buffer);
|
||||
}
|
||||
|
||||
template <class OutT, class BufferT>
|
||||
static inline void test(BufferT* buffer, std::string_view in_val, const char* const conv) {
|
||||
sprintf(buffer, conv, in_val.data()); // in_val is zero terminated in this program
|
||||
OutT out_val(buffer);
|
||||
}
|
||||
};
|
||||
|
||||
struct structure_sscanf {
|
||||
@@ -117,6 +128,12 @@ struct structure_sscanf {
|
||||
OutT out_val;
|
||||
sscanf(in_val.begin(), conv, &out_val);
|
||||
}
|
||||
|
||||
template <class OutT, class BufferT>
|
||||
static inline void test(BufferT* /*buffer*/, std::string_view in_val, const char* const conv) {
|
||||
OutT out_val;
|
||||
sscanf(in_val.data(), conv, &out_val); // in_val is zero terminated in this program
|
||||
}
|
||||
};
|
||||
|
||||
struct structure_fake {
|
||||
@@ -226,7 +243,7 @@ static inline void perf_test_impl(const FromT& in_val, const char* const conv) {
|
||||
lexical_cast_time.count(),
|
||||
ss_constr_time.count(),
|
||||
ss_noconstr_time.count(),
|
||||
boost::is_same<SprintfT, structure_fake>::value ? fake_test_value : printf_time.count()
|
||||
std::is_same<SprintfT, structure_fake>::value ? fake_test_value : printf_time.count()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -312,6 +329,12 @@ struct to_array_50 {
|
||||
}
|
||||
};
|
||||
|
||||
struct to_string_view {
|
||||
std::string_view operator()(const char* const c) const {
|
||||
return std::string_view{c};
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
BOOST_ASSERT(argc >= 2);
|
||||
std::string output_path(argv[1]);
|
||||
@@ -354,6 +377,7 @@ int main(int argc, char** argv) {
|
||||
string_like_test_set<to_uchar_conv>("unsigned char*");
|
||||
string_like_test_set<to_schar_conv>("signed char*");
|
||||
string_like_test_set<to_iterator_range>("iterator_range<char*>");
|
||||
string_like_test_set<to_string_view>("std::string_view");
|
||||
string_like_test_set<to_array_50>("array<char, 50>");
|
||||
|
||||
perf_test<int, structure_fake>("int->int", 100, "");
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
# Copyright Antony Polukhin, 2021-2026.
|
||||
#
|
||||
# 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
|
||||
|
||||
if(NOT TARGET tests)
|
||||
add_custom_target(tests)
|
||||
endif()
|
||||
|
||||
function(boost_lexical_cast_add_test_impl test_name test_file libs)
|
||||
add_executable(${test_name} ${test_file})
|
||||
target_link_libraries(${test_name} PRIVATE ${libs})
|
||||
add_test(NAME ${test_name} COMMAND ${test_name})
|
||||
add_dependencies(tests ${test_name})
|
||||
endfunction()
|
||||
|
||||
function(boost_lexical_cast_add_test name libs)
|
||||
set(test_name lexical_cast_${name})
|
||||
set(test_file ${name}.cpp)
|
||||
boost_lexical_cast_add_test_impl(${test_name} ${test_file} "Boost::lexical_cast;${libs}")
|
||||
endfunction()
|
||||
|
||||
boost_lexical_cast_add_test(lexical_cast_test Boost::type_traits)
|
||||
boost_lexical_cast_add_test(loopback_test "")
|
||||
boost_lexical_cast_add_test(abstract_test "")
|
||||
boost_lexical_cast_add_test(noncopyable_test "")
|
||||
boost_lexical_cast_add_test(vc8_bug_test "")
|
||||
boost_lexical_cast_add_test(implicit_convert "")
|
||||
boost_lexical_cast_add_test(wchars_test "")
|
||||
boost_lexical_cast_add_test(float_types_test "")
|
||||
|
||||
if(NOT MSVC)
|
||||
# Make sure that LexicalCast works the same way as some of the C++ Standard Libraries
|
||||
boost_lexical_cast_add_test_impl(lexical_cast_float_types_non_opt float_types_test.cpp Boost::lexical_cast)
|
||||
target_compile_definitions(lexical_cast_float_types_non_opt PRIVATE BOOST_LEXICAL_CAST_DETAIL_TEST_ON_OLD)
|
||||
endif()
|
||||
|
||||
boost_lexical_cast_add_test(inf_nan_test "")
|
||||
boost_lexical_cast_add_test(containers_test "")
|
||||
boost_lexical_cast_add_test(empty_input_test Boost::range)
|
||||
boost_lexical_cast_add_test(pointers_test "")
|
||||
|
||||
if(MSVC)
|
||||
add_executable(lexical_cast_typedefed_wchar_test_compile typedefed_wchar_test.cpp)
|
||||
target_compile_options(lexical_cast_typedefed_wchar_test_compile PRIVATE "/Zc:wchar_t-")
|
||||
|
||||
boost_lexical_cast_add_test(typedefed_wchar_test_runtime "")
|
||||
target_compile_options(lexical_cast_typedefed_wchar_test_runtime PRIVATE "/Zc:wchar_t-")
|
||||
endif()
|
||||
|
||||
boost_lexical_cast_add_test(no_locale_test Boost::range)
|
||||
target_compile_definitions(lexical_cast_no_locale_test
|
||||
PRIVATE
|
||||
BOOST_NO_STD_LOCALE
|
||||
BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
|
||||
)
|
||||
|
||||
boost_lexical_cast_add_test_impl(lexical_cast_no_exceptions_test no_exceptions_test.cpp "Boost::container;Boost::range")
|
||||
target_include_directories(lexical_cast_no_exceptions_test PRIVATE ../include)
|
||||
target_compile_definitions(lexical_cast_no_exceptions_test
|
||||
PRIVATE
|
||||
_HAS_EXCEPTIONS=0 # MSVC stdlib
|
||||
_STLP_NO_EXCEPTIONS # STLPort
|
||||
)
|
||||
if(MSVC)
|
||||
target_compile_definitions(lexical_cast_no_exceptions_test PRIVATE BOOST_NO_EXCEPTIONS)
|
||||
endif()
|
||||
target_compile_options(lexical_cast_no_exceptions_test PRIVATE "-fno-exceptions")
|
||||
|
||||
boost_lexical_cast_add_test(iterator_range_test Boost::range)
|
||||
boost_lexical_cast_add_test(string_view_test Boost::utility)
|
||||
boost_lexical_cast_add_test(arrays_test Boost::array)
|
||||
boost_lexical_cast_add_test(integral_types_test Boost::type_traits)
|
||||
boost_lexical_cast_add_test(stream_detection_test "")
|
||||
boost_lexical_cast_add_test(stream_traits_test "Boost::array;Boost::range;Boost::utility")
|
||||
|
||||
boost_lexical_cast_add_test(filesystem_test Boost::filesystem)
|
||||
boost_lexical_cast_add_test(try_lexical_convert "")
|
||||
|
||||
file(GLOB EXAMPLE_FILES "../example/*.cpp")
|
||||
foreach (testsourcefile ${EXAMPLE_FILES})
|
||||
get_filename_component(testname ${testsourcefile} NAME_WE)
|
||||
boost_lexical_cast_add_test_impl(lexical_cast_example_${testname} ${testsourcefile} "Boost::variant;Boost::date_time")
|
||||
endforeach()
|
||||
+24
-8
@@ -1,18 +1,20 @@
|
||||
# Copyright (C) 2001-2003 Douglas Gregor
|
||||
# Copyright (C) Antony Polukhin, 2011-2023
|
||||
# Copyright Antony Polukhin, 2011-2026.
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
|
||||
require-b2 5.0.1 ;
|
||||
import-search /boost/config/checks ;
|
||||
import config : requires ;
|
||||
import testing ;
|
||||
import feature ;
|
||||
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
[ requires cxx11_rvalue_references ]
|
||||
<library>/boost/lexical_cast//boost_lexical_cast
|
||||
[ requires cxx11_rvalue_references cxx11_static_assert cxx11_template_aliases ]
|
||||
<link>static
|
||||
<toolset>gcc-4.7:<cxxflags>-ftrapv
|
||||
<toolset>gcc-4.6:<cxxflags>-ftrapv
|
||||
@@ -29,6 +31,10 @@ project
|
||||
# Not a lexical_cast related warning: boost/mpl/aux_/preprocessed/gcc/greater_equal.hpp:78:1: warning: empty macro arguments are a C99 feature [-Wc99-extensions]
|
||||
# boost/mpl/iter_fold.hpp:45:1: warning: empty macro arguments are a C99 feature [-Wc99-extensions]
|
||||
<toolset>clang:<cxxflags>-Wno-c99-extensions
|
||||
|
||||
<library>/boost/array//boost_array
|
||||
<library>/boost/range//boost_range
|
||||
<library>/boost/utility//boost_utility
|
||||
;
|
||||
|
||||
# Thanks to Steven Watanabe for helping with <nowchar> feature
|
||||
@@ -42,21 +48,30 @@ test-suite conversion
|
||||
[ run abstract_test.cpp ]
|
||||
[ run noncopyable_test.cpp ]
|
||||
[ run vc8_bug_test.cpp ]
|
||||
[ run implicit_convert.cpp ]
|
||||
[ run wchars_test.cpp ]
|
||||
[ run float_types_test.cpp ]
|
||||
|
||||
# Make sure that LexicalCast works the same way as some of the C++ Standard Libraries
|
||||
[ run float_types_test.cpp : : : <define>BOOST_LEXICAL_CAST_DETAIL_TEST_ON_OLD
|
||||
<toolset>msvc:<build>no # could have outdated behavior in some border cases
|
||||
<target-os>darwin:<build>no # may have outdated behavior in some border cases
|
||||
: float_types_non_opt
|
||||
]
|
||||
|
||||
[ run inf_nan_test.cpp ]
|
||||
[ run containers_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-long-long <toolset>clang:<cxxflags>-Wno-long-long ]
|
||||
[ run empty_input_test.cpp ]
|
||||
[ run pointers_test.cpp ]
|
||||
[ compile typedefed_wchar_test.cpp : <toolset>msvc:<nowchar>on ]
|
||||
[ compile typedefed_wchar_test.cpp : <toolset>msvc:<nowchar>on <library>/boost/date_time//boost_date_time ]
|
||||
[ run typedefed_wchar_test_runtime.cpp : : : <toolset>msvc:<nowchar>on <toolset>msvc,<stdlib>stlport:<build>no ]
|
||||
[ run no_locale_test.cpp : : : <define>BOOST_NO_STD_LOCALE <define>BOOST_LEXICAL_CAST_ASSUME_C_LOCALE ]
|
||||
[ run no_exceptions_test.cpp : : : <exception-handling>off
|
||||
<define>_HAS_EXCEPTIONS=0 # MSVC stdlib
|
||||
<define>_STLP_NO_EXCEPTIONS # STLPort
|
||||
-<library>/boost/test//boost_unit_test_framework # uses lightweight_test
|
||||
]
|
||||
[ run iterator_range_test.cpp ]
|
||||
[ run string_view_test.cpp ]
|
||||
[ run arrays_test.cpp : : :
|
||||
<toolset>msvc:<cxxflags>/wd4512 # assignment operator could not be generated
|
||||
]
|
||||
@@ -64,14 +79,15 @@ test-suite conversion
|
||||
[ run stream_detection_test.cpp ]
|
||||
[ run stream_traits_test.cpp ]
|
||||
[ compile-fail to_pointer_test.cpp ]
|
||||
[ run filesystem_test.cpp ../../filesystem/build//boost_filesystem/<link>static ]
|
||||
[ compile-fail from_volatile.cpp ]
|
||||
[ run filesystem_test.cpp /boost/filesystem//boost_filesystem : : : <toolset>gcc,<target-os>windows:<build>no ] # Boost.Atomic no longer supports MinGW
|
||||
[ run try_lexical_convert.cpp ]
|
||||
;
|
||||
|
||||
# Assuring that examples compile and run. Adding sources from `example` directory to the `conversion` test suite.
|
||||
for local p in [ glob ../example/*.cpp ]
|
||||
{
|
||||
conversion += [ run $(p) ] ;
|
||||
conversion += [ run $(p) : : : <library>/boost/variant//boost_variant <library>/boost/date_time//boost_date_time ] ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Sergey Shandar 2005, Alexander Nasonov, 2007.
|
||||
// Copyright Antony Polukhin, 2023.
|
||||
// Copyright Antony Polukhin, 2023-2026.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
@@ -12,10 +12,10 @@
|
||||
// Test abstract class. Bug 1358600:
|
||||
// http://sf.net/tracker/?func=detail&aid=1358600&group_id=7586&atid=107586
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
class A
|
||||
{
|
||||
public:
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
# subject to 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)
|
||||
#
|
||||
# Copyright Antony Polukhin, 2016-2023.
|
||||
# Copyright Antony Polukhin, 2016-2026.
|
||||
|
||||
#
|
||||
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
|
||||
|
||||
+10
-5
@@ -2,18 +2,18 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2023.
|
||||
// Copyright Antony Polukhin, 2012-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS) && !defined(_LIBCPP_VERSION) && !defined(BOOST_MSVC)
|
||||
@@ -61,7 +61,7 @@ static void testing_template_array_output_on_spec_value(T val)
|
||||
BOOST_TEST_THROWS(lexical_cast<sshort_arr_type>(val), boost::bad_lexical_cast);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING)
|
||||
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING) && !defined(_LIBCPP_VERSION)
|
||||
typedef ArrayT<wchar_t, 300> warr_type;
|
||||
typedef ArrayT<wchar_t, 3> wshort_arr_type;
|
||||
std::wstring wethalon(L"100");
|
||||
@@ -156,7 +156,7 @@ static void testing_template_array_output_on_char_value()
|
||||
BOOST_TEST_THROWS(lexical_cast<sshort_arr_type>(val), boost::bad_lexical_cast);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING)
|
||||
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING) && !defined(_LIBCPP_VERSION)
|
||||
typedef ArrayT<wchar_t, 4> warr_type;
|
||||
typedef ArrayT<wchar_t, 3> wshort_arr_type;
|
||||
std::wstring wethalon(L"100");
|
||||
@@ -238,11 +238,13 @@ static void testing_template_array_output_on_char_value()
|
||||
|
||||
void testing_boost_array_output_conversion()
|
||||
{
|
||||
#ifndef _LIBCPP_VERSION
|
||||
testing_template_array_output_on_char_value<boost::array>();
|
||||
testing_template_array_output_on_spec_value<boost::array>(100);
|
||||
testing_template_array_output_on_spec_value<boost::array>(static_cast<short>(100));
|
||||
testing_template_array_output_on_spec_value<boost::array>(static_cast<unsigned short>(100));
|
||||
testing_template_array_output_on_spec_value<boost::array>(static_cast<unsigned int>(100));
|
||||
#endif
|
||||
}
|
||||
|
||||
void testing_std_array_output_conversion()
|
||||
@@ -344,7 +346,10 @@ static void testing_generic_array_input_conversion()
|
||||
|
||||
void testing_boost_array_input_conversion()
|
||||
{
|
||||
#ifndef _LIBCPP_VERSION
|
||||
testing_generic_array_input_conversion<boost::array>();
|
||||
#endif
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
void testing_std_array_input_conversion()
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
# Copyright (c) 2016-2025 Antony Polukhin
|
||||
# Copyright (c) 2025-2026 Fedor Osetrov
|
||||
# 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
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...4.0)
|
||||
|
||||
project(lexical_cast_subdir_test LANGUAGES CXX)
|
||||
|
||||
set(deps
|
||||
|
||||
# Library dependencies
|
||||
config
|
||||
container
|
||||
core
|
||||
throw_exception
|
||||
|
||||
# Test dependencies
|
||||
algorithm
|
||||
array
|
||||
align
|
||||
assert
|
||||
atomic
|
||||
bind
|
||||
compat
|
||||
concept_check
|
||||
container_hash
|
||||
conversion
|
||||
date_time
|
||||
describe
|
||||
detail
|
||||
exception
|
||||
filesystem
|
||||
function
|
||||
function_types
|
||||
functional
|
||||
fusion
|
||||
integer
|
||||
intrusive
|
||||
io
|
||||
iterator
|
||||
move
|
||||
mp11
|
||||
mpl
|
||||
numeric/conversion
|
||||
optional
|
||||
predef
|
||||
preprocessor
|
||||
range
|
||||
regex
|
||||
scope
|
||||
smart_ptr
|
||||
static_assert
|
||||
system
|
||||
test
|
||||
tokenizer
|
||||
tuple
|
||||
type_index
|
||||
type_traits
|
||||
typeof
|
||||
unordered
|
||||
utility
|
||||
variant
|
||||
variant2
|
||||
winapi
|
||||
)
|
||||
|
||||
foreach(dep IN LISTS deps)
|
||||
add_subdirectory(../../../${dep} boostorg/${dep})
|
||||
endforeach()
|
||||
|
||||
enable_testing()
|
||||
add_subdirectory(../../ boostorg/lexical_cast)
|
||||
|
||||
if (BOOST_USE_MODULES)
|
||||
add_executable(boost_lexical_cast_module_usage ../modules/usage_sample.cpp)
|
||||
target_link_libraries(boost_lexical_cast_module_usage PRIVATE Boost::lexical_cast)
|
||||
add_test(NAME boost_lexical_cast_module_usage COMMAND boost_lexical_cast_module_usage)
|
||||
endif()
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/container/string.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
void testing_boost_containers_basic_string()
|
||||
|
||||
@@ -2,21 +2,22 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#include "escape_struct.hpp"
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "escape_struct.hpp"
|
||||
|
||||
using namespace boost;
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2020.
|
||||
// Copyright Antony Polukhin, 2020-2026.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2013-2023.
|
||||
// Copyright Antony Polukhin, 2013-2026.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
@@ -10,11 +10,11 @@
|
||||
//
|
||||
// Test lexical_cast usage with long filesystem::path. Bug 7704.
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
void test_filesystem()
|
||||
{
|
||||
boost::filesystem::path p;
|
||||
|
||||
+88
-24
@@ -2,20 +2,33 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#ifndef BOOST_LEXICAL_CAST_DETAIL_TEST_ON_OLD
|
||||
#include <boost/lexical_cast/detail/type_traits.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#else
|
||||
// Make sure that tests work the same way on non-optimized version
|
||||
#include "lexical_cast_old.hpp"
|
||||
#include <boost/lexical_cast/detail/type_traits.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BOOST_TEST_CLOSE_FRACTION
|
||||
// Naiive, but works for most tests in this file
|
||||
#define BOOST_TEST_CLOSE_FRACTION(x, y, eps) BOOST_TEST(x - y + eps <= eps * 2)
|
||||
#define BOOST_TEST_CLOSE_FRACTION(x, y, eps) \
|
||||
BOOST_TEST(x - y + eps <= eps * 2); \
|
||||
BOOST_TEST(y - x + eps <= eps * 2);
|
||||
#endif
|
||||
|
||||
#if (defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__NetBSD__) \
|
||||
@@ -293,8 +306,8 @@ void test_float_typess_for_overflows()
|
||||
BOOST_TEST_THROWS(lexical_cast<test_t>("1"+s_max_value), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<test_t>("9"+s_max_value), bad_lexical_cast);
|
||||
#endif
|
||||
|
||||
if ( is_same<test_t,float>::value )
|
||||
#if !(defined(_LIBCPP_VERSION) && defined(BOOST_LEXICAL_CAST_DETAIL_TEST_ON_OLD))
|
||||
if ( std::is_same<test_t,float>::value )
|
||||
{
|
||||
BOOST_TEST_THROWS(lexical_cast<test_t>( (std::numeric_limits<double>::max)() ), bad_lexical_cast);
|
||||
BOOST_TEST(
|
||||
@@ -303,6 +316,13 @@ void test_float_typess_for_overflows()
|
||||
&& lexical_cast<test_t>( (std::numeric_limits<double>::min)() )
|
||||
<= (std::numeric_limits<double>::min)() + std::numeric_limits<test_t>::epsilon()
|
||||
);
|
||||
|
||||
BOOST_TEST(
|
||||
(std::numeric_limits<double>::min)() / 2 - std::numeric_limits<test_t>::epsilon()
|
||||
<= lexical_cast<test_t>( (std::numeric_limits<double>::min)() / 2 )
|
||||
&& lexical_cast<test_t>( (std::numeric_limits<double>::min)() / 2 )
|
||||
<= (std::numeric_limits<double>::min)() / 2 + std::numeric_limits<test_t>::epsilon()
|
||||
);
|
||||
}
|
||||
|
||||
if ( sizeof(test_t) < sizeof(long double) )
|
||||
@@ -314,7 +334,15 @@ void test_float_typess_for_overflows()
|
||||
&& lexical_cast<test_t>( (std::numeric_limits<long double>::min)() )
|
||||
<= (std::numeric_limits<long double>::min)() + std::numeric_limits<test_t>::epsilon()
|
||||
);
|
||||
|
||||
BOOST_TEST(
|
||||
(std::numeric_limits<long double>::min)() / 2 - std::numeric_limits<test_t>::epsilon()
|
||||
<= lexical_cast<test_t>( (std::numeric_limits<long double>::min)() / 2 )
|
||||
&& lexical_cast<test_t>( (std::numeric_limits<long double>::min)() / 2 )
|
||||
<= (std::numeric_limits<long double>::min)() / 2 + std::numeric_limits<test_t>::epsilon()
|
||||
);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef CHECK_CLOSE_ABS_DIFF
|
||||
@@ -488,6 +516,7 @@ void test_conversion_from_to_float()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_conversion_from_to_float()
|
||||
{
|
||||
test_conversion_from_to_float<float>();
|
||||
@@ -505,27 +534,50 @@ void test_conversion_from_to_long_double()
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
|
||||
template <typename Float>
|
||||
double make_volatile_float_roundtrip() {
|
||||
volatile Float v = 1.0;
|
||||
return static_cast<double>(boost::lexical_cast<Float>(v));
|
||||
}
|
||||
|
||||
void test_volatile_floats()
|
||||
template <class Integral, class Float>
|
||||
void test_conversion_integral_float()
|
||||
{
|
||||
// Inspired by test case from https://github.com/boostorg/lexical_cast/issues/50
|
||||
BOOST_TEST_EQ(make_volatile_float_roundtrip<float>(), 1.0);
|
||||
BOOST_TEST_EQ(make_volatile_float_roundtrip<double>(), 1.0);
|
||||
#if !defined(BOOST_LEXICAL_CAST_NO_LONG_DOUBLE_MATH_FUNCTIONS)
|
||||
BOOST_TEST_EQ(make_volatile_float_roundtrip<long double>(), 1.0);
|
||||
BOOST_TEST_CLOSE_FRACTION(lexical_cast<Float>(static_cast<Float>(1)), static_cast<Float>(1), std::numeric_limits<Float>::epsilon());
|
||||
BOOST_TEST_CLOSE_FRACTION(lexical_cast<Float>(static_cast<Float>(1.1234)), static_cast<Float>(1.1234), std::numeric_limits<Float>::epsilon());
|
||||
BOOST_TEST_CLOSE_FRACTION(lexical_cast<Float>(static_cast<Float>(-1.1234)), static_cast<Float>(-1.1234), std::numeric_limits<Float>::epsilon());
|
||||
|
||||
BOOST_TEST_CLOSE_FRACTION(lexical_cast<Float>(static_cast<Integral>(0)), static_cast<Float>(0), std::numeric_limits<Float>::epsilon());
|
||||
BOOST_TEST_CLOSE_FRACTION(lexical_cast<Float>(static_cast<Integral>(1)), static_cast<Float>(1), std::numeric_limits<Float>::epsilon());
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
BOOST_TEST_CLOSE_FRACTION(lexical_cast<Float>((std::numeric_limits<Integral>::max)()), static_cast<Float>((std::numeric_limits<Integral>::max)()), std::numeric_limits<Float>::epsilon());
|
||||
BOOST_TEST_CLOSE_FRACTION(lexical_cast<Float>((std::numeric_limits<Integral>::min)()), static_cast<Float>((std::numeric_limits<Integral>::min)()), std::numeric_limits<Float>::epsilon());
|
||||
#endif
|
||||
|
||||
volatile float v = 1.0;
|
||||
BOOST_TEST_EQ(boost::lexical_cast<float>(v), 1.0f);
|
||||
#if !defined(BOOST_LEXICAL_CAST_NO_LONG_DOUBLE_MATH_FUNCTIONS)
|
||||
BOOST_TEST_EQ(boost::lexical_cast<long double>(v), 1.0);
|
||||
#endif
|
||||
BOOST_TEST_EQ(lexical_cast<Integral>(static_cast<Float>(0.0)), 0);
|
||||
BOOST_TEST_EQ(lexical_cast<Integral>(static_cast<Float>(1.0)), 1);
|
||||
BOOST_TEST_EQ(lexical_cast<Integral>(static_cast<Float>(8.0)), 8);
|
||||
BOOST_TEST_EQ(lexical_cast<Integral>(static_cast<Float>(16.0)), 16);
|
||||
|
||||
if (boost::detail::lcast::is_signed<Integral>::value) {
|
||||
BOOST_TEST_EQ(lexical_cast<Integral>(static_cast<Float>(-1.0)), -1);
|
||||
BOOST_TEST_EQ(lexical_cast<Integral>(static_cast<Float>(-8.0)), -8);
|
||||
BOOST_TEST_EQ(lexical_cast<Integral>(static_cast<Float>(-16.0)), -16);
|
||||
} else {
|
||||
BOOST_TEST_EQ(lexical_cast<Integral>(static_cast<Float>(-1.0)), (std::numeric_limits<Integral>::max)());
|
||||
BOOST_TEST_EQ(lexical_cast<Integral>(static_cast<Float>(-8.0)), (std::numeric_limits<Integral>::max)() - 7);
|
||||
BOOST_TEST_EQ(lexical_cast<Integral>(static_cast<Float>(-16.0)), (std::numeric_limits<Integral>::max)() - 15);
|
||||
}
|
||||
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(static_cast<Float>(0.5)), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(static_cast<Float>(-0.5)), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(static_cast<Float>(1.5)), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(static_cast<Float>(-1.5)), bad_lexical_cast);
|
||||
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>((std::numeric_limits<Float>::min)()), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>((std::numeric_limits<Float>::max)()), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>((std::numeric_limits<Float>::epsilon)()), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>((std::numeric_limits<Float>::lowest)()), bad_lexical_cast);
|
||||
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(std::numeric_limits<Float>::quiet_NaN()), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(-std::numeric_limits<Float>::quiet_NaN()), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(std::numeric_limits<Float>::infinity()), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(-std::numeric_limits<Float>::infinity()), bad_lexical_cast);
|
||||
}
|
||||
|
||||
|
||||
@@ -534,7 +586,19 @@ int main()
|
||||
test_conversion_from_to_float();
|
||||
test_conversion_from_to_double();
|
||||
test_conversion_from_to_long_double();
|
||||
test_volatile_floats();
|
||||
|
||||
test_conversion_integral_float<int, float>();
|
||||
test_conversion_integral_float<int, double>();
|
||||
test_conversion_integral_float<unsigned short, float>();
|
||||
test_conversion_integral_float<unsigned short, double>();
|
||||
test_conversion_integral_float<short, float>();
|
||||
test_conversion_integral_float<short, double>();
|
||||
test_conversion_integral_float<long int, float>();
|
||||
test_conversion_integral_float<long int, double>();
|
||||
test_conversion_integral_float<long long, float>();
|
||||
test_conversion_integral_float<long long, double>();
|
||||
test_conversion_integral_float<unsigned long long, float>();
|
||||
test_conversion_integral_float<unsigned long long, double>();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright Antony Polukhin, 2013-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
volatile int i = 42;
|
||||
boost::lexical_cast<std::string>(i);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
// Copyright Antony Polukhin, 2023-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
struct oops {
|
||||
operator int () const {
|
||||
return 41;
|
||||
}
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const oops&) {
|
||||
return os << 42;
|
||||
}
|
||||
|
||||
struct oops2 {
|
||||
operator double () const {
|
||||
return 1.12;
|
||||
}
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const oops2&) {
|
||||
return os << 2;
|
||||
}
|
||||
|
||||
struct Value {
|
||||
explicit Value(double x) : x(x) {}
|
||||
|
||||
operator double() const {
|
||||
return x;
|
||||
}
|
||||
|
||||
double x;
|
||||
};
|
||||
|
||||
int main() {
|
||||
BOOST_TEST_EQ(boost::lexical_cast<int>(oops{}), 42);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<std::string>(oops{}), "42");
|
||||
|
||||
BOOST_TEST_EQ(boost::lexical_cast<double>(oops2{}), 2);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<std::string>(oops2{}), "2");
|
||||
|
||||
Value longer_that_1_digit(128);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<std::string>(longer_that_1_digit), "128");
|
||||
|
||||
// iostreams have default precision 6, see [basic.ios.cons]
|
||||
const double precision_more_than_6_digits = 1.23456789123;
|
||||
// At the moment we do not set the precision for types that use conversion
|
||||
// operators for ostreaming, so the below test pass. We do not set precision
|
||||
// for user provided `operator<<`, types with conversion operators follow
|
||||
// the same design decision for now.
|
||||
BOOST_TEST_NE(
|
||||
boost::lexical_cast<std::string>(Value(precision_more_than_6_digits)),
|
||||
boost::lexical_cast<std::string>(precision_more_than_6_digits)
|
||||
);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
+53
-4
@@ -2,19 +2,20 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/core/cmath.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
|
||||
#define BOOST_LCAST_NO_WCHAR_T
|
||||
#endif
|
||||
@@ -46,7 +47,7 @@ bool is_neg_nan(T value)
|
||||
* It is a IA64 feature, or it is a boost::math feature, not a lexical_cast bug */
|
||||
#if defined(__ia64__) || defined(_M_IA64)
|
||||
return (boost::core::isnan)(value)
|
||||
&& ( boost::is_same<T, long double >::value || (boost::core::signbit)(value) );
|
||||
&& ( std::is_same<T, long double >::value || (boost::core::signbit)(value) );
|
||||
#else
|
||||
return (boost::core::isnan)(value) && (boost::core::signbit)(value);
|
||||
#endif
|
||||
@@ -167,11 +168,36 @@ void test_inf_nan_templated()
|
||||
void test_inf_nan_float()
|
||||
{
|
||||
test_inf_nan_templated<float >();
|
||||
|
||||
BOOST_TEST(is_pos_nan(lexical_cast<float>(std::numeric_limits<float>::quiet_NaN())));
|
||||
BOOST_TEST(is_neg_nan(lexical_cast<float>(-std::numeric_limits<float>::quiet_NaN())));
|
||||
BOOST_TEST(is_pos_inf(lexical_cast<float>(std::numeric_limits<float>::infinity())));
|
||||
BOOST_TEST(is_neg_inf(lexical_cast<float>(-std::numeric_limits<float>::infinity())));
|
||||
|
||||
BOOST_TEST(is_pos_nan(lexical_cast<float>(std::numeric_limits<double>::quiet_NaN())));
|
||||
BOOST_TEST(is_neg_nan(lexical_cast<float>(-std::numeric_limits<double>::quiet_NaN())));
|
||||
BOOST_TEST(is_pos_inf(lexical_cast<float>(std::numeric_limits<double>::infinity())));
|
||||
BOOST_TEST(is_neg_inf(lexical_cast<float>(-std::numeric_limits<double>::infinity())));
|
||||
}
|
||||
|
||||
void test_inf_nan_double()
|
||||
{
|
||||
test_inf_nan_templated<double >();
|
||||
|
||||
BOOST_TEST(is_pos_nan(lexical_cast<double>(std::numeric_limits<float>::quiet_NaN())));
|
||||
BOOST_TEST(is_neg_nan(lexical_cast<double>(-std::numeric_limits<float>::quiet_NaN())));
|
||||
BOOST_TEST(is_pos_inf(lexical_cast<double>(std::numeric_limits<float>::infinity())));
|
||||
BOOST_TEST(is_neg_inf(lexical_cast<double>(-std::numeric_limits<float>::infinity())));
|
||||
|
||||
BOOST_TEST(is_pos_nan(lexical_cast<double>(std::numeric_limits<double>::quiet_NaN())));
|
||||
BOOST_TEST(is_neg_nan(lexical_cast<double>(-std::numeric_limits<double>::quiet_NaN())));
|
||||
BOOST_TEST(is_pos_inf(lexical_cast<double>(std::numeric_limits<double>::infinity())));
|
||||
BOOST_TEST(is_neg_inf(lexical_cast<double>(-std::numeric_limits<double>::infinity())));
|
||||
|
||||
BOOST_TEST(is_pos_nan(lexical_cast<double>(std::numeric_limits<long double>::quiet_NaN())));
|
||||
BOOST_TEST(is_neg_nan(lexical_cast<double>(-std::numeric_limits<long double>::quiet_NaN())));
|
||||
BOOST_TEST(is_pos_inf(lexical_cast<double>(std::numeric_limits<long double>::infinity())));
|
||||
BOOST_TEST(is_neg_inf(lexical_cast<double>(-std::numeric_limits<long double>::infinity())));
|
||||
}
|
||||
|
||||
void test_inf_nan_long_double()
|
||||
@@ -183,11 +209,34 @@ void test_inf_nan_long_double()
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
template <class Integral>
|
||||
void test_inf_nan_to_integral()
|
||||
{
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(std::numeric_limits<float>::quiet_NaN()), boost::bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(-std::numeric_limits<float>::quiet_NaN()), boost::bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(std::numeric_limits<float>::infinity()), boost::bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(-std::numeric_limits<float>::infinity()), boost::bad_lexical_cast);
|
||||
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(std::numeric_limits<double>::quiet_NaN()), boost::bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(-std::numeric_limits<double>::quiet_NaN()), boost::bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(std::numeric_limits<double>::infinity()), boost::bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(-std::numeric_limits<double>::infinity()), boost::bad_lexical_cast);
|
||||
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(std::numeric_limits<long double>::quiet_NaN()), boost::bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(-std::numeric_limits<long double>::quiet_NaN()), boost::bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(std::numeric_limits<long double>::infinity()), boost::bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(lexical_cast<Integral>(-std::numeric_limits<long double>::infinity()), boost::bad_lexical_cast);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_inf_nan_float();
|
||||
test_inf_nan_double();
|
||||
test_inf_nan_long_double();
|
||||
|
||||
test_inf_nan_to_integral<int>();
|
||||
test_inf_nan_to_integral<bool>();
|
||||
test_inf_nan_to_integral<short>();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Copyright Terje Sletteb and Kevlin Henney, 2005.
|
||||
// Copyright Alexander Nasonov, 2006.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
@@ -19,17 +19,20 @@
|
||||
//
|
||||
#define _SCL_SECURE_NO_WARNINGS
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast/detail/type_traits.hpp>
|
||||
|
||||
#include <boost/type_traits/integral_promotion.hpp>
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if (defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)) \
|
||||
&& !(defined(BOOST_MSVC) && BOOST_MSVC < 1300)
|
||||
@@ -40,7 +43,8 @@
|
||||
#define BOOST_LCAST_NO_WCHAR_T
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_INT128) && !defined(BOOST_LEXICAL_CAST_TEST_NO_128_INTS)
|
||||
// There's no typeinfo for unsigned __int128 in Xcode_15.0.1
|
||||
#if defined(BOOST_HAS_INT128) && !defined(BOOST_LEXICAL_CAST_TEST_NO_128_INTS) && !defined(__APPLE__)
|
||||
# define BOOST_LCAST_TEST_128 1
|
||||
#endif
|
||||
|
||||
@@ -171,9 +175,9 @@ void test_conversion_from_integral_to_string(CharT)
|
||||
T const max_val = (limits::max)();
|
||||
T const half_max_val = max_val / 2;
|
||||
T const cnt = lcast_integral_test_counter; // to suppress warnings
|
||||
unsigned int const counter = cnt < half_max_val ? cnt : half_max_val;
|
||||
T const counter = cnt < half_max_val ? cnt : half_max_val;
|
||||
|
||||
unsigned int i;
|
||||
T i = 0;
|
||||
|
||||
// Test values around min:
|
||||
t = min_val;
|
||||
@@ -248,7 +252,7 @@ void test_conversion_from_string_to_integral(CharT)
|
||||
}
|
||||
|
||||
typedef typename boost::integral_promotion<T>::type promoted;
|
||||
if ( !(boost::is_same<T, promoted>::value) )
|
||||
if ( !(std::is_same<T, promoted>::value) )
|
||||
{
|
||||
promoted prom = max_val;
|
||||
s = to_str<CharT>(max_val);
|
||||
@@ -267,10 +271,10 @@ void test_conversion_from_string_to_integral(CharT)
|
||||
{
|
||||
T const half_max_val = max_val / 2;
|
||||
T const cnt = lcast_integral_test_counter; // to suppress warnings
|
||||
unsigned int const counter = cnt < half_max_val ? cnt : half_max_val;
|
||||
T const counter = cnt < half_max_val ? cnt : half_max_val;
|
||||
|
||||
T t;
|
||||
unsigned int i;
|
||||
T i;
|
||||
|
||||
// Test values around min:
|
||||
t = min_val;
|
||||
@@ -563,7 +567,7 @@ template <typename SignedT>
|
||||
void test_integral_conversions_on_min_max_impl()
|
||||
{
|
||||
typedef SignedT signed_t;
|
||||
typedef typename boost::make_unsigned<signed_t>::type unsigned_t;
|
||||
typedef typename boost::detail::lcast::make_unsigned<signed_t>::type unsigned_t;
|
||||
|
||||
typedef std::numeric_limits<signed_t> s_limits;
|
||||
typedef std::numeric_limits<unsigned_t> uns_limits;
|
||||
@@ -599,37 +603,31 @@ void test_integral_conversions_on_min_max()
|
||||
|
||||
}
|
||||
|
||||
template <typename Int>
|
||||
int make_volatile_int_roundtrip() {
|
||||
volatile Int v = 42;
|
||||
return static_cast<int>(boost::lexical_cast<Int>(v));
|
||||
}
|
||||
void test_negative_integral() {
|
||||
// From https://github.com/boostorg/lexical_cast/issues/45
|
||||
BOOST_TEST_EQ(boost::lexical_cast<int>("-6575543"), -6575543);
|
||||
|
||||
void test_volatile_integers()
|
||||
{
|
||||
// Inspired by test case from https://github.com/boostorg/lexical_cast/issues/50
|
||||
BOOST_TEST_EQ(make_volatile_int_roundtrip<signed char>(), 42);
|
||||
BOOST_TEST_EQ(make_volatile_int_roundtrip<signed short>(), 42);
|
||||
BOOST_TEST_EQ(make_volatile_int_roundtrip<signed int>(), 42);
|
||||
BOOST_TEST_EQ(make_volatile_int_roundtrip<signed long>(), 42);
|
||||
BOOST_TEST_EQ(make_volatile_int_roundtrip<signed long long>(), 42);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<int>(-6575543), -6575543);
|
||||
|
||||
BOOST_TEST_EQ(make_volatile_int_roundtrip<unsigned char>(), 42);
|
||||
BOOST_TEST_EQ(make_volatile_int_roundtrip<unsigned short>(), 42);
|
||||
BOOST_TEST_EQ(make_volatile_int_roundtrip<unsigned int>(), 42);
|
||||
BOOST_TEST_EQ(make_volatile_int_roundtrip<unsigned long>(), 42);
|
||||
BOOST_TEST_EQ(make_volatile_int_roundtrip<unsigned long long>(), 42);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<int>("+6575543"), +6575543);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<int>(6575543), 6575543);
|
||||
|
||||
volatile int v = 42;
|
||||
BOOST_TEST_EQ(boost::lexical_cast<signed short>(v), 42);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<signed int>(v), 42);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<signed long>(v), 42);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<signed long long>(v), 42);
|
||||
if (sizeof(short) == 2 && CHAR_BIT == 8) {
|
||||
BOOST_TEST_EQ(boost::lexical_cast<short>("-32768"), -32768);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<short>(-32768), -32768);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<unsigned short>("-32768"), 32768);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<unsigned short>(-32768), 32768);
|
||||
|
||||
BOOST_TEST_EQ(boost::lexical_cast<unsigned short>(v), 42u);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<unsigned int>(v), 42u);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<unsigned long>(v), 42u);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<unsigned long long>(v), 42u);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<unsigned short>(65535), 65535);
|
||||
|
||||
BOOST_TEST_THROWS(boost::lexical_cast<unsigned short>(-65536), bad_lexical_cast);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<unsigned short>(-65535), 1);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<unsigned short>(-65534), 2);
|
||||
|
||||
BOOST_TEST_THROWS(boost::lexical_cast<short>(65535), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(boost::lexical_cast<short>(-65536), bad_lexical_cast);
|
||||
BOOST_TEST_THROWS(boost::lexical_cast<short>(-65535), bad_lexical_cast);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -651,7 +649,8 @@ int main()
|
||||
test_conversion_from_to_uint128();
|
||||
#endif
|
||||
test_integral_conversions_on_min_max();
|
||||
test_volatile_integers();
|
||||
|
||||
test_negative_integral();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2023.
|
||||
// Copyright Antony Polukhin, 2012-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
|
||||
@@ -136,7 +136,7 @@ void test_it_range_using_char(CharT* one, CharT* eleven)
|
||||
#endif
|
||||
BOOST_TEST_EQ(lexical_cast<class_with_user_defined_sream_operators>(crng2), 1);
|
||||
|
||||
#ifndef BOOST_LCAST_NO_WCHAR_T
|
||||
#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(_LIBCPP_VERSION)
|
||||
BOOST_TEST(lexical_cast<std::wstring>(rng1) == L"1");
|
||||
BOOST_TEST(lexical_cast<std::wstring>(crng1) == L"1");
|
||||
BOOST_TEST(lexical_cast<std::wstring>(rng2) == L"1");
|
||||
@@ -191,7 +191,7 @@ void test_signed_char_iterator_ranges()
|
||||
|
||||
void test_wchar_iterator_ranges()
|
||||
{
|
||||
#ifndef BOOST_LCAST_NO_WCHAR_T
|
||||
#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(_LIBCPP_VERSION)
|
||||
typedef wchar_t test_char_type;
|
||||
test_char_type data1[] = L"1";
|
||||
test_char_type data2[] = L"11";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -32,10 +32,9 @@
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <type_traits>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/detail/lcast_precision.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#ifdef BOOST_NO_STRINGSTREAM
|
||||
#include <strstream>
|
||||
@@ -43,6 +42,10 @@
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_USE_MODULES)
|
||||
#undef BOOST_USE_MODULES
|
||||
#endif
|
||||
#include <boost/lexical_cast/detail/lcast_precision.hpp>
|
||||
#include <boost/lexical_cast/bad_lexical_cast.hpp>
|
||||
#include <boost/lexical_cast/detail/widest_char.hpp>
|
||||
|
||||
@@ -115,7 +118,7 @@ namespace boost {
|
||||
template<typename InputStreamable>
|
||||
bool operator>>(InputStreamable &output)
|
||||
{
|
||||
return !is_pointer<InputStreamable>::value &&
|
||||
return !std::is_pointer<InputStreamable>::value &&
|
||||
stream >> output &&
|
||||
stream.get() == traits_type::eof();
|
||||
}
|
||||
@@ -159,7 +162,7 @@ namespace boost {
|
||||
|
||||
typedef std::char_traits<char_type> traits;
|
||||
detail::lexical_stream<Target, Source, traits> interpreter;
|
||||
Target result;
|
||||
Target result{};
|
||||
|
||||
if(!(interpreter << arg && interpreter >> result))
|
||||
boost::conversion::detail::throw_bad_cast<Source, Target>();
|
||||
+19
-32
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Copyright Terje Sletteb and Kevlin Henney, 2005.
|
||||
// Copyright Alexander Nasonov, 2006.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
@@ -19,8 +19,6 @@
|
||||
//
|
||||
#define _SCL_SECURE_NO_WARNINGS
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
@@ -31,6 +29,8 @@
|
||||
#include <algorithm> // std::transform
|
||||
#include <memory>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if (defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)) \
|
||||
&& !(defined(BOOST_MSVC) && BOOST_MSVC < 1300)
|
||||
#define LCAST_TEST_LONGLONG
|
||||
@@ -390,19 +390,6 @@ void test_no_whitespace_stripping()
|
||||
BOOST_TEST_THROWS(lexical_cast<int>("123 "), bad_lexical_cast);
|
||||
}
|
||||
|
||||
void test_volatile_types_conversions()
|
||||
{
|
||||
volatile int i1 = 100000;
|
||||
BOOST_TEST_EQ("100000", boost::lexical_cast<std::string>(i1));
|
||||
|
||||
volatile const int i2 = 100000;
|
||||
BOOST_TEST_EQ("100000", boost::lexical_cast<std::string>(i2));
|
||||
|
||||
volatile const long int i3 = 1000000;
|
||||
BOOST_TEST_EQ("1000000", boost::lexical_cast<std::string>(i3));
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
void test_traits()
|
||||
{
|
||||
typedef std::basic_string<char, my_traits<char> > my_string;
|
||||
@@ -411,6 +398,8 @@ void test_traits()
|
||||
BOOST_TEST(boost::lexical_cast<char>(s) == s[0]);
|
||||
BOOST_TEST(boost::lexical_cast<my_string>(s) == s);
|
||||
BOOST_TEST(boost::lexical_cast<my_string>(-1) == "-1");
|
||||
BOOST_TEST(boost::lexical_cast<int>(my_string("42")) == 42);
|
||||
BOOST_TEST(boost::lexical_cast<double>(my_string("1.0")) == 1.0);
|
||||
}
|
||||
|
||||
void test_wtraits()
|
||||
@@ -420,9 +409,9 @@ void test_wtraits()
|
||||
my_string const s(L"s");
|
||||
BOOST_TEST(boost::lexical_cast<wchar_t>(s) == s[0]);
|
||||
BOOST_TEST(boost::lexical_cast<my_string>(s) == s);
|
||||
//BOOST_TEST(boost::lexical_cast<my_string>(-1) == L"-1");
|
||||
// Commented out because gcc 3.3 doesn't support this:
|
||||
// basic_ostream<wchar_t, my_traits<wchar_t> > o; o << -1;
|
||||
BOOST_TEST(boost::lexical_cast<my_string>(-1) == L"-1");
|
||||
BOOST_TEST(boost::lexical_cast<int>(my_string(L"42")) == 42);
|
||||
BOOST_TEST(boost::lexical_cast<double>(my_string(L"1.0")) == 1.0);
|
||||
}
|
||||
|
||||
void test_allocator()
|
||||
@@ -469,8 +458,6 @@ void test_wallocator()
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void test_char_types_conversions()
|
||||
{
|
||||
@@ -536,21 +523,27 @@ void operators_overload_test()
|
||||
}
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
|
||||
void test_char16_conversions()
|
||||
{
|
||||
// There's no std::ctype<char16_t> in Xcode_15.0.1
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS) && !defined(__APPLE__)
|
||||
BOOST_TEST(u"100" == lexical_cast<std::u16string>(u"100"));
|
||||
#if !defined(_LIBCPP_VERSION) // libc++ also does not have std::ctype<char16_t>
|
||||
BOOST_TEST(u"1" == lexical_cast<std::u16string>(u'1'));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
|
||||
void test_char32_conversions()
|
||||
{
|
||||
// There's no std::ctype<char32_t> in Xcode_15.0.1
|
||||
#if !defined(BOOST_NO_CXX11_CHAR32_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS) && !defined(__APPLE__)
|
||||
BOOST_TEST(U"100" == lexical_cast<std::u32string>(U"100"));
|
||||
#if !defined(_LIBCPP_VERSION) // libc++ also does not have std::ctype<char32_t>
|
||||
BOOST_TEST(U"1" == lexical_cast<std::u32string>(U'1'));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_getting_pointer_to_function()
|
||||
{
|
||||
@@ -590,22 +583,16 @@ int main()
|
||||
#endif
|
||||
test_bad_lexical_cast();
|
||||
test_no_whitespace_stripping();
|
||||
test_volatile_types_conversions();
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
test_traits();
|
||||
test_wtraits();
|
||||
test_allocator();
|
||||
test_wallocator();
|
||||
#endif
|
||||
|
||||
test_char_types_conversions();
|
||||
operators_overload_test();
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
|
||||
test_char16_conversions();
|
||||
#endif
|
||||
#if !defined(BOOST_NO_CXX11_CHAR32_T) && !defined(BOOST_NO_CXX11_UNICODE_LITERALS)
|
||||
test_char32_conversions();
|
||||
#endif
|
||||
test_getting_pointer_to_function();
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Alexander Nasonov, 2006.
|
||||
// Copyright Antony Polukhin, 2023.
|
||||
// Copyright Antony Polukhin, 2023-2026.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
@@ -12,10 +12,10 @@
|
||||
// Test round-tripping conversion FPT -> string -> FPT,
|
||||
// where FPT is Floating Point Type.
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if (defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__NetBSD__) \
|
||||
|| (defined(__hppa) && !defined(__OpenBSD__)) || (defined(__NO_LONG_DOUBLE_MATH) && (DBL_MANT_DIG != LDBL_MANT_DIG))) \
|
||||
|| defined(__MINGW64__)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2023.
|
||||
// Copyright Antony Polukhin, 2012-2026.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
@@ -16,12 +16,16 @@
|
||||
#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800)
|
||||
#endif
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(BOOST_USE_MODULES)
|
||||
#undef BOOST_USE_MODULES
|
||||
#endif
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "escape_struct.hpp"
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2023.
|
||||
// Copyright Antony Polukhin, 2012-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
@@ -17,6 +15,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
// Testing compilation and some basic usage with BOOST_NO_STD_LOCALE
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Alexander Nasonov, 2007.
|
||||
// Copyright Antony Polukhin, 2023.
|
||||
// Copyright Antony Polukhin, 2023-2026.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
@@ -11,11 +11,12 @@
|
||||
//
|
||||
// Test that Source can be non-copyable.
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
class Noncopyable : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -2,16 +2,18 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2023.
|
||||
// Copyright Antony Polukhin, 2012-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM)
|
||||
typedef std::strstream ss_t;
|
||||
#else
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
|
||||
///////////////////////// char streamable classes ///////////////////////////////////////////
|
||||
@@ -28,12 +29,12 @@ std::istream& operator >> (std::istream& istr, const streamable_easy&) {
|
||||
|
||||
struct streamable_medium { enum ENU {value = 1}; };
|
||||
template <class CharT>
|
||||
typename boost::enable_if<boost::is_same<CharT, char>, std::basic_ostream<CharT>&>::type
|
||||
typename std::enable_if<std::is_same<CharT, char>::value, std::basic_ostream<CharT>&>::type
|
||||
operator << (std::basic_ostream<CharT>& ostr, const streamable_medium&) {
|
||||
return ostr << streamable_medium::value;
|
||||
}
|
||||
template <class CharT>
|
||||
typename boost::enable_if<boost::is_same<CharT, char>, std::basic_istream<CharT>&>::type
|
||||
typename std::enable_if<std::is_same<CharT, char>::value, std::basic_istream<CharT>&>::type
|
||||
operator >> (std::basic_istream<CharT>& istr, const streamable_medium&) {
|
||||
int i; istr >> i; BOOST_TEST_EQ(i, streamable_medium::value);
|
||||
return istr;
|
||||
@@ -41,12 +42,12 @@ operator >> (std::basic_istream<CharT>& istr, const streamable_medium&) {
|
||||
|
||||
struct streamable_hard { enum ENU {value = 2}; };
|
||||
template <class CharT, class TraitsT>
|
||||
typename boost::enable_if<boost::is_same<CharT, char>, std::basic_ostream<CharT, TraitsT>&>::type
|
||||
typename std::enable_if<std::is_same<CharT, char>::value, std::basic_ostream<CharT, TraitsT>&>::type
|
||||
operator << (std::basic_ostream<CharT, TraitsT>& ostr, const streamable_hard&) {
|
||||
return ostr << streamable_hard::value;
|
||||
}
|
||||
template <class CharT, class TraitsT>
|
||||
typename boost::enable_if<boost::is_same<CharT, char>, std::basic_istream<CharT, TraitsT>&>::type
|
||||
typename std::enable_if<std::is_same<CharT, char>::value, std::basic_istream<CharT, TraitsT>&>::type
|
||||
operator >> (std::basic_istream<CharT, TraitsT>& istr, const streamable_hard&) {
|
||||
int i; istr >> i; BOOST_TEST_EQ(i, streamable_hard::value);
|
||||
return istr;
|
||||
@@ -77,12 +78,12 @@ std::wistream& operator >> (std::wistream& istr, const wstreamable_easy&) {
|
||||
|
||||
struct wstreamable_medium { enum ENU {value = 5}; };
|
||||
template <class CharT>
|
||||
typename boost::enable_if<boost::is_same<CharT, wchar_t>, std::basic_ostream<CharT>& >::type
|
||||
typename std::enable_if<std::is_same<CharT, wchar_t>::value, std::basic_ostream<CharT>& >::type
|
||||
operator << (std::basic_ostream<CharT>& ostr, const wstreamable_medium&) {
|
||||
return ostr << wstreamable_medium::value;
|
||||
}
|
||||
template <class CharT>
|
||||
typename boost::enable_if<boost::is_same<CharT, wchar_t>, std::basic_istream<CharT>& >::type
|
||||
typename std::enable_if<std::is_same<CharT, wchar_t>::value, std::basic_istream<CharT>& >::type
|
||||
operator >> (std::basic_istream<CharT>& istr, const wstreamable_medium&) {
|
||||
int i; istr >> i; BOOST_TEST_EQ(i, wstreamable_medium::value);
|
||||
return istr;
|
||||
@@ -90,12 +91,12 @@ operator >> (std::basic_istream<CharT>& istr, const wstreamable_medium&) {
|
||||
|
||||
struct wstreamable_hard { enum ENU {value = 6}; };
|
||||
template <class CharT, class TraitsT>
|
||||
typename boost::enable_if<boost::is_same<CharT, wchar_t>, std::basic_ostream<CharT, TraitsT>&>::type
|
||||
typename std::enable_if<std::is_same<CharT, wchar_t>::value, std::basic_ostream<CharT, TraitsT>&>::type
|
||||
operator << (std::basic_ostream<CharT, TraitsT>& ostr, const wstreamable_hard&) {
|
||||
return ostr << wstreamable_hard::value;
|
||||
}
|
||||
template <class CharT, class TraitsT>
|
||||
typename boost::enable_if<boost::is_same<CharT, wchar_t>, std::basic_istream<CharT, TraitsT>&>::type
|
||||
typename std::enable_if<std::is_same<CharT, wchar_t>::value, std::basic_istream<CharT, TraitsT>&>::type
|
||||
operator >> (std::basic_istream<CharT, TraitsT>& istr, const wstreamable_hard&) {
|
||||
int i; istr >> i; BOOST_TEST_EQ(i, wstreamable_hard::value);
|
||||
return istr;
|
||||
@@ -255,13 +256,14 @@ void test_istream_character_detection() {
|
||||
test_bistr_instr_impl<bistreamable_hard2>();
|
||||
}
|
||||
|
||||
|
||||
struct wistreamble_ostreamable { enum ENU {value = 200}; };
|
||||
std::ostream& operator << (std::ostream& ostr, const wistreamble_ostreamable&) {
|
||||
return ostr << wistreamble_ostreamable::value;
|
||||
}
|
||||
std::wistream& operator >> (std::wistream& istr, const wistreamble_ostreamable&) {
|
||||
int i; istr >> i; BOOST_TEST_EQ(i, wistreamble_ostreamable::value);
|
||||
int i = 100;
|
||||
istr >> i;
|
||||
BOOST_TEST_EQ(i, wistreamble_ostreamable::value);
|
||||
return istr;
|
||||
}
|
||||
|
||||
@@ -277,6 +279,7 @@ std::istream& operator >> (std::istream& istr, const istreamble_wostreamable&) {
|
||||
void test_mixed_stream_character_detection() {
|
||||
//boost::lexical_cast<std::wstring>(std::string("qwe")); // TODO: ALLOW IT AS EXTENSION!
|
||||
|
||||
BOOST_TEST_EQ(boost::lexical_cast<int>(wistreamble_ostreamable::value), wistreamble_ostreamable::value);
|
||||
boost::lexical_cast<wistreamble_ostreamable>(wistreamble_ostreamable::value);
|
||||
BOOST_TEST_EQ(boost::lexical_cast<int>(wistreamble_ostreamable()), wistreamble_ostreamable::value);
|
||||
|
||||
|
||||
+100
-57
@@ -1,46 +1,59 @@
|
||||
// Unit test for boost::lexical_cast.
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2023.
|
||||
// Copyright Antony Polukhin, 2012-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#if defined(BOOST_USE_MODULES)
|
||||
#undef BOOST_USE_MODULES
|
||||
#endif
|
||||
#include <boost/lexical_cast/detail/converter_lexical.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/container/string.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/utility/string_view.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
template <class T>
|
||||
struct is_optimized_stream : std::false_type {};
|
||||
|
||||
template <class CharT, class Traits, std::size_t CharacterBufferSize>
|
||||
struct is_optimized_stream< boost::detail::lcast::optimized_src_stream<CharT, Traits, CharacterBufferSize> > : std::true_type {};
|
||||
|
||||
template <class Source, class Target>
|
||||
static void assert_optimized_stream()
|
||||
{
|
||||
BOOST_TEST((is_optimized_stream<
|
||||
typename boost::detail::lexical_converter_impl<Source, Target>::from_src_stream
|
||||
>::value));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static void test_optimized_types_to_string_const()
|
||||
{
|
||||
namespace de = boost::detail;
|
||||
typedef de::lexical_cast_stream_traits<T, std::string> trait_1;
|
||||
BOOST_TEST(!trait_1::is_source_input_not_optimized_t::value);
|
||||
BOOST_TEST((boost::is_same<typename trait_1::src_char_t, char>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_1::target_char_t, char>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_1::char_type, char>::value));
|
||||
BOOST_TEST(!trait_1::is_string_widening_required_t::value);
|
||||
BOOST_TEST(!trait_1::is_source_input_not_optimized_t::value);
|
||||
BOOST_TEST((std::is_same<typename trait_1::src_char_t, char>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_1::target_char_t, char>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_1::char_type, char>::value));
|
||||
assert_optimized_stream<T, std::string>();
|
||||
assert_optimized_stream<T, boost::container::string>();
|
||||
|
||||
typedef de::lexical_cast_stream_traits<const T, std::string> trait_2;
|
||||
BOOST_TEST(!trait_2::is_source_input_not_optimized_t::value);
|
||||
BOOST_TEST((boost::is_same<typename trait_2::src_char_t, char>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_2::target_char_t, char>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_2::char_type, char>::value));
|
||||
BOOST_TEST(!trait_2::is_string_widening_required_t::value);
|
||||
BOOST_TEST(!trait_2::is_source_input_not_optimized_t::value);
|
||||
BOOST_TEST((std::is_same<typename trait_2::src_char_t, char>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_2::target_char_t, char>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_2::char_type, char>::value));
|
||||
|
||||
typedef de::lexical_cast_stream_traits<T, std::wstring> trait_3;
|
||||
BOOST_TEST(!trait_3::is_source_input_not_optimized_t::value);
|
||||
BOOST_TEST((boost::is_same<typename trait_3::src_char_t, char>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_3::target_char_t, wchar_t>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_3::char_type, wchar_t>::value));
|
||||
|
||||
BOOST_TEST((boost::detail::is_character<typename trait_3::no_cv_src>::value != trait_3::is_string_widening_required_t::value));
|
||||
|
||||
BOOST_TEST(!trait_3::is_source_input_not_optimized_t::value);
|
||||
BOOST_TEST((std::is_same<typename trait_3::src_char_t, char>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_3::target_char_t, wchar_t>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_3::char_type, wchar_t>::value));
|
||||
assert_optimized_stream<T, std::wstring>();
|
||||
assert_optimized_stream<T, boost::container::wstring>();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,50 +64,65 @@ static void test_optimized_types_to_string()
|
||||
|
||||
namespace de = boost::detail;
|
||||
typedef de::lexical_cast_stream_traits<std::string, T> trait_4;
|
||||
BOOST_TEST(!trait_4::is_source_input_not_optimized_t::value);
|
||||
BOOST_TEST((boost::is_same<typename trait_4::src_char_t, char>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_4::target_char_t, char>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_4::char_type, char>::value));
|
||||
BOOST_TEST(!trait_4::is_string_widening_required_t::value);
|
||||
BOOST_TEST(!trait_4::is_source_input_not_optimized_t::value);
|
||||
BOOST_TEST((std::is_same<typename trait_4::src_char_t, char>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_4::target_char_t, char>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_4::char_type, char>::value));
|
||||
assert_optimized_stream<std::string, T>();
|
||||
|
||||
typedef de::lexical_cast_stream_traits<const std::string, T> trait_5;
|
||||
BOOST_TEST(!trait_5::is_source_input_not_optimized_t::value);
|
||||
BOOST_TEST((boost::is_same<typename trait_5::src_char_t, char>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_5::target_char_t, char>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_5::char_type, char>::value));
|
||||
BOOST_TEST(!trait_5::is_string_widening_required_t::value);
|
||||
BOOST_TEST(!trait_5::is_source_input_not_optimized_t::value);
|
||||
BOOST_TEST((std::is_same<typename trait_5::src_char_t, char>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_5::target_char_t, char>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_5::char_type, char>::value));
|
||||
|
||||
typedef de::lexical_cast_stream_traits<const std::wstring, T> trait_6;
|
||||
BOOST_TEST(!trait_6::is_source_input_not_optimized_t::value);
|
||||
BOOST_TEST((boost::is_same<typename trait_6::src_char_t, wchar_t>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_6::target_char_t, char>::value));
|
||||
BOOST_TEST((boost::is_same<typename trait_6::char_type, wchar_t>::value));
|
||||
BOOST_TEST(!trait_6::is_string_widening_required_t::value);
|
||||
BOOST_TEST((std::is_same<typename trait_6::src_char_t, wchar_t>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_6::target_char_t, char>::value));
|
||||
BOOST_TEST((std::is_same<typename trait_6::char_type, wchar_t>::value));
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
static void test_optimized_types_to_x_string()
|
||||
{
|
||||
test_optimized_types_to_string<T>();
|
||||
assert_optimized_stream<std::wstring, T>();
|
||||
assert_optimized_stream<boost::container::wstring, T>();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
static void test_optimized_types_to_wstring()
|
||||
{
|
||||
assert_optimized_stream<std::wstring, T>();
|
||||
assert_optimized_stream<T, std::wstring>();
|
||||
assert_optimized_stream<boost::container::wstring, T>();
|
||||
assert_optimized_stream<T, boost::container::wstring>();
|
||||
}
|
||||
|
||||
void test_metafunctions()
|
||||
{
|
||||
test_optimized_types_to_string<bool>();
|
||||
test_optimized_types_to_string<char>();
|
||||
test_optimized_types_to_string<unsigned char>();
|
||||
test_optimized_types_to_string<signed char>();
|
||||
test_optimized_types_to_string<short>();
|
||||
test_optimized_types_to_string<unsigned short>();
|
||||
test_optimized_types_to_string<int>();
|
||||
test_optimized_types_to_string<unsigned int>();
|
||||
test_optimized_types_to_string<long>();
|
||||
test_optimized_types_to_string<unsigned long>();
|
||||
test_optimized_types_to_x_string<bool>();
|
||||
test_optimized_types_to_x_string<char>();
|
||||
test_optimized_types_to_x_string<unsigned char>();
|
||||
test_optimized_types_to_x_string<signed char>();
|
||||
test_optimized_types_to_x_string<short>();
|
||||
test_optimized_types_to_x_string<unsigned short>();
|
||||
test_optimized_types_to_x_string<int>();
|
||||
test_optimized_types_to_x_string<unsigned int>();
|
||||
test_optimized_types_to_x_string<long>();
|
||||
test_optimized_types_to_x_string<unsigned long>();
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
test_optimized_types_to_string<boost::ulong_long_type>();
|
||||
test_optimized_types_to_string<boost::long_long_type>();
|
||||
test_optimized_types_to_x_string<boost::ulong_long_type>();
|
||||
test_optimized_types_to_x_string<boost::long_long_type>();
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
test_optimized_types_to_string<unsigned __int64>();
|
||||
test_optimized_types_to_string<__int64>();
|
||||
test_optimized_types_to_x_string<unsigned __int64>();
|
||||
test_optimized_types_to_x_string<__int64>();
|
||||
#endif
|
||||
|
||||
test_optimized_types_to_string<float>();
|
||||
test_optimized_types_to_string<double>();
|
||||
test_optimized_types_to_string<long double>();
|
||||
test_optimized_types_to_string<std::string>();
|
||||
test_optimized_types_to_string<char*>();
|
||||
//test_optimized_types_to_string<char[5]>();
|
||||
@@ -139,10 +167,25 @@ void test_metafunctions()
|
||||
test_optimized_types_to_string_const<std::array<const unsigned char, 5> >();
|
||||
test_optimized_types_to_string_const<std::array<const signed char, 1> >();
|
||||
test_optimized_types_to_string_const<std::array<const signed char, 5> >();
|
||||
|
||||
test_optimized_types_to_wstring<std::array<wchar_t, 42>>();
|
||||
test_optimized_types_to_wstring<std::array<const wchar_t, 42>>();
|
||||
#endif
|
||||
|
||||
test_optimized_types_to_wstring<wchar_t*>();
|
||||
test_optimized_types_to_wstring<const wchar_t*>();
|
||||
test_optimized_types_to_wstring<boost::iterator_range<const wchar_t*>>();
|
||||
test_optimized_types_to_wstring<boost::iterator_range<wchar_t*>>();
|
||||
|
||||
test_optimized_types_to_string<boost::string_view>();
|
||||
test_optimized_types_to_wstring<boost::basic_string_view<wchar_t>>();
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
|
||||
test_optimized_types_to_string<std::string_view>();
|
||||
test_optimized_types_to_wstring<std::basic_string_view<wchar_t>>();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
test_metafunctions();
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// Unit test for boost::lexical_cast.
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
|
||||
#include <boost/utility/string_view.hpp>
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
|
||||
template <class StringView>
|
||||
void test_string_view_conversion() {
|
||||
using boost::lexical_cast;
|
||||
|
||||
StringView sw = "1";
|
||||
BOOST_TEST_EQ(lexical_cast<std::string>(sw), "1");
|
||||
BOOST_TEST_EQ(lexical_cast<int>(sw), 1);
|
||||
|
||||
sw = StringView("a\0b", 3);
|
||||
BOOST_TEST_EQ(lexical_cast<std::string>(sw), std::string("a\0b", 3));
|
||||
|
||||
sw = StringView("a\0b", 4);
|
||||
BOOST_TEST_EQ(lexical_cast<std::string>(sw), std::string("a\0b", 4));
|
||||
|
||||
sw = StringView("\0a\0", 3);
|
||||
BOOST_TEST_EQ(lexical_cast<std::string>(sw), std::string("\0a\0", 3));
|
||||
}
|
||||
|
||||
int main() {
|
||||
test_string_view_conversion<boost::string_view>();
|
||||
|
||||
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
|
||||
test_string_view_conversion<std::string_view>();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2013-2023.
|
||||
// Copyright Antony Polukhin, 2013-2026.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2014-2023.
|
||||
// Copyright Antony Polukhin, 2014-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/lexical_cast/try_lexical_convert.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast/try_lexical_convert.hpp>
|
||||
|
||||
using namespace boost::conversion;
|
||||
|
||||
void try_uncommon_cases()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
@@ -32,9 +32,22 @@ void test_typedefed_wchar_t_runtime()
|
||||
test_typedefed_wchar_t(L'0');
|
||||
}
|
||||
|
||||
void test_unsigned_short_to_wstring()
|
||||
{
|
||||
// Test case from https://github.com/boostorg/lexical_cast/issues/89
|
||||
unsigned short number = 4550;
|
||||
|
||||
auto res1 = boost::lexical_cast<std::wstring>(number);
|
||||
BOOST_TEST(res1 == L"4550");
|
||||
|
||||
auto res2 = boost::lexical_cast<std::string>(number);
|
||||
BOOST_TEST_EQ(res2, "4550");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_typedefed_wchar_t_runtime();
|
||||
test_unsigned_short_to_wstring();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -12,12 +12,14 @@
|
||||
// implementation has changed and it does not use stringstream for casts
|
||||
// to integral types
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(disable: 4127) // conditional expression is constant
|
||||
|
||||
@@ -2,15 +2,20 @@
|
||||
//
|
||||
// See http://www.boost.org for most recent version, including documentation.
|
||||
//
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
// Copyright Antony Polukhin, 2011-2026.
|
||||
//
|
||||
// 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).
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#if defined(BOOST_USE_MODULES)
|
||||
#undef BOOST_USE_MODULES
|
||||
#endif
|
||||
#include <boost/lexical_cast/detail/lcast_char_constants.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
|
||||
#define BOOST_LCAST_NO_WCHAR_T
|
||||
|
||||
Reference in New Issue
Block a user