Compare commits

..

519 Commits

Author SHA1 Message Date
Antony Polukhin 827dd94c68 Update copyright years 2026-01-02 13:40:23 +03:00
dependabot[bot] 782e083f61 Bump actions/checkout from 2 to 6 (#32)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-26 22:04:25 +03:00
Antony Polukhin 1e6424563d Add dependabot 2025-12-24 20:19:01 +03:00
Antony Polukhin 6632ca9309 Run all the tests in CMake, add CMake runs into CI. Drop dependency on Boost.SmartPtr as it is not used by the library for some time (#31) 2025-10-07 20:26:12 +03:00
Antony Polukhin b74a4c34cb Allow using polymorphic_downcast and polymorphic_cast in constexpr (#30) 2025-06-27 20:42:54 +03:00
Antony Polukhin 452adac97f CI fixes 2025-06-27 17:33:16 +03:00
Antony Polukhin 5f82d5aa7d Update regression test links in Readme and fix typos 2025-06-19 09:27:35 +03:00
Antony Polukhin 9d64c899df Update copyright years 2025-01-05 19:37:56 +03:00
Antony Polukhin 35a71f0701 Prefer "using" over "typedef" 2024-12-17 16:37:40 +03:00
René Ferdinand Rivera Morell 8a860e05d0 Add support for modular build structure. (#29)
This is part of the effort to make the Boost libraries "modular" for build and consumption. See https://lists.boost.org/Archives/boost/2024/01/255704.php and https://github.com/grafikrobot/boost-b2-modular/blob/b2-modular/README.adoc for more information.

This PR depends on the following other PRs being merged to both develop and master branches of the respective repos:

- https://github.com/boostorg/boost/pull/854

This PR will be changed to ready for review, i.e. not draft, when the above are merged. Do not merge this one until that time.
2024-08-24 12:37:14 +03:00
Danil Sidoruk 9f285ef0c4 Remove mentions of lexical_cast in docs (#28)
lexical_cast isn't a part of Boost.Conversion, it's part of Boost.Lexical_Cast
2024-01-21 14:13:03 +03:00
Antony Polukhin 5f36c2c710 Update tests requirements 2024-01-21 14:08:52 +03:00
Antony Polukhin 41e62ed851 Update copyright years 2024-01-07 13:20:12 +03:00
Antony Polukhin 5cf5f78376 Restore Boost::smart_ptr dependency in CMakeLists 2023-08-27 13:28:45 +03:00
Antony Polukhin 5a3587c988 simplify code 2023-08-26 21:45:41 +03:00
Antony Polukhin f7f3c9b5ce Merge branch 'drop-cpp03' into develop 2023-08-25 15:00:40 +03:00
Antony Polukhin 668030fcd6 Remove hard error about C++11 requirement and update CI 2023-08-25 14:59:53 +03:00
Mohammad Nejati 0d60a3f7ce Use relative URL for redirect in index.html (#26) 2023-08-12 10:53:42 +03:00
Antony Polukhin 0ff5adc258 Merge pull request #27 from boostorg/drop-cpp03
Drop c++03 support
2023-08-12 10:45:01 +03:00
Antony Polukhin 2598281d10 drop c++03 support 2023-08-10 18:52:03 +03:00
Antony Polukhin a1104f580c update CI setup 2023-05-21 09:42:12 +03:00
Antony Polukhin 9a03296816 add C++03 deprecation warnings 2023-05-14 19:49:21 +03:00
Antony Polukhin 7ba0984b34 Update copyright years 2023-01-19 10:01:52 +03:00
Antony Polukhin 4ae8b4d495 update copyright years 2022-01-30 12:52:42 +03:00
Antony Polukhin 71b6a864a4 do not use depth 1 for checkouts in CI 2021-09-20 21:46:36 +03:00
Antony Polukhin b2a49138cf Fix appveyor CI checks for MSVC 2021-09-11 12:29:42 +03:00
Antony Polukhin 00f06d3549 Update appveyor CI badge link 2021-09-11 12:08:35 +03:00
Antony Polukhin 968dfd47f1 remove clang-9 from test matrix 2021-09-10 20:39:56 +03:00
Antony Polukhin f0fe02f7d6 use builtin rules for toolsets 2021-09-10 20:32:09 +03:00
Antony Polukhin 19b5a1cf29 remove ubuntu-16.04 matrix entries in CI 2021-09-10 20:25:17 +03:00
Peter Dimov 1a2e4fd8ef Update CMakeLists.txt 2021-06-10 01:17:02 +03:00
Antony Polukhin 8d1721f312 use HTTPS links in Readme 2021-04-27 10:07:49 +03:00
Antony Polukhin c6ab56e983 memory sanitizer is triggered by libstdc++, so disable it 2021-04-25 21:17:35 +03:00
Antony Polukhin 1c62347706 use more sanitizers 2021-04-25 20:32:49 +03:00
Antony Polukhin 56becb8fee update of the Github Actions to the latest version 2021-04-24 19:13:17 +03:00
Antony Polukhin 67ae26b0f0 update Readme links [skip ci] 2021-04-22 11:25:59 +03:00
Antony Polukhin d4e593120d update CI: depinst.py the Boost.Filesystem before copying the library content 2021-04-21 21:06:41 +03:00
Antony Polukhin 76ed70b0b1 update CI: overwrite the target dir 2021-04-21 20:59:46 +03:00
Antony Polukhin 4b7d551907 remove drone CI in favour of default github actions from CppAlliance 2021-04-21 20:53:38 +03:00
Antony Polukhin 9e3216d22f make boost::implicit_cast constexpr (fixes #25) 2021-04-21 20:51:14 +03:00
Antony Polukhin 4e557d31d1 fix broken links (fixes #23) 2021-04-21 20:50:26 +03:00
Antony Polukhin 46695ffb86 update CI: use workflow from boost.Any 2021-04-21 20:47:14 +03:00
Antony Polukhin c1c098fac1 update CI (5): update readme links 2021-04-18 21:20:23 +03:00
Antony Polukhin b171fe1ff6 update CI (4): more fixes for coverage 2021-04-18 20:14:15 +03:00
Antony Polukhin a178d1a691 update CI (3): fixes for coverage 2021-04-18 20:05:00 +03:00
Antony Polukhin 5176e189b8 update CI (2): inspect tool options 2021-04-18 19:50:46 +03:00
Antony Polukhin 49e6421271 update CI (1): simplify and decompose ci.yaml 2021-04-18 19:42:45 +03:00
Antony Polukhin a0bfc39077 Merge pull request #24 from sdarwin/githubactions
GitHub Actions config
2021-04-18 14:11:15 +03:00
sdarwin 2bf2bba4be Add GitHub Actions config [ci skip] 2021-03-04 18:22:48 +00:00
Antony Polukhin f882ab890d Merge pull request #21 from sdarwin/drone
Drone config
2021-01-27 10:28:28 +03:00
sdarwin e0bb75e096 add drone config [ci skip] 2021-01-26 15:29:35 +00:00
Antony Polukhin 80b9240f2e Merge pull request #20 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-20 10:34:58 +03:00
Edward Diener df86cb59c4 [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-19 12:48:45 -05:00
Antony Polukhin 4fec53f3db update copyright years 2021-01-03 13:57:41 +03:00
Antony Polukhin db398fc1c8 Merge pull request #19 from sdarwin/lcov
update lcov in .travis.yml
2021-01-02 17:06:49 +03:00
sdarwin 1576ff7be6 update lcov in .travis.yml 2020-12-24 15:50:18 +00:00
Antony Polukhin 9540be42b4 CI fixes (3) 2020-07-06 10:34:54 +03:00
Antony Polukhin 7624b70a6d index.html update 2020-07-06 10:15:07 +03:00
Antony Polukhin 78fc22c66a CI fixes (2) 2020-07-06 10:13:52 +03:00
Antony Polukhin f1d5059c75 fix broken link 2020-07-05 23:24:00 +03:00
Antony Polukhin f2e83915c3 CI fixes (1) 2020-07-05 19:30:18 +03:00
Antony Polukhin e0a40b7067 CI fixes 2020-07-05 19:27:05 +03:00
Antony Polukhin 1dd1c98b79 Merge pull request #18 from Mike-Devel/patch-1
[CMake] Add boost core to dependency list
2020-05-02 07:51:37 +03:00
Mike-Devel a1788bc31b [CMake] Add boost core to dependency list
Used in  boost/polymorphic_cast.hpp
2020-04-29 11:52:40 +02:00
Antony Polukhin 58c33270a2 Use boost::addressof and update docs 2020-01-25 10:59:32 +03:00
Julien DELACROIX e130cd860c boost::polymorphic_downcast only supports raw pointer cast, which is a gap compared to static_cast.
To make it clear:
       Base* base = new Base();

       static_cast<Derived*>(base)                 ===> OK
       static_cast<Derived&>(*base)                ===> OK

       boost::polymorphic_downcast<Derived*>(base)  ===> OK
       boost::polymorphic_downcast<Derived&>(*base) ===> IMPOSSIBLE

    boost::polymorphic_downcast being a kind of "debug-safe version" of
    static_cast, it should provide the same capabilities.

    This patch extend boost::polymorphic_downcast to support references just
    like static_cast does.
    This is achieved by introducing a partial specialization for references.
    Unit tests have been updated accordingly.
2019-12-09 08:51:10 +01:00
Antony Polukhin 9d4a518e74 CI fix (2) 2019-06-29 11:28:49 +03:00
Antony Polukhin 1525157560 CI fix 2019-06-29 11:06:42 +03:00
Antony Polukhin 3421136ef0 test on clang-7 instead of clang-5.0 2019-06-29 10:59:47 +03:00
Antony Polukhin 441d4e4e1b Update appveyor.yml 2019-04-24 22:10:38 +03:00
Antony Polukhin b3f8e9f014 Merge pull request #16 from Mike-Devel/min_cmake
[CMake] Add minimal cmake support
2019-03-03 21:54:59 +03:00
Mike-Devel 24f2769eb7 [CMake] Use PascalCase in project name 2019-03-03 10:11:11 +01:00
Mike Dev 6806d99529 [CMake] Add minimal cmake support
- CMake file only supports add_subdirectory workflow.
- Provides target Boost::conversion, but doesn't support
  installation or running unit tests.
2019-03-03 09:38:35 +01:00
Antony Polukhin e38c0753ef update copyright years 2019-01-30 23:13:06 +03:00
Antony Polukhin 6b3395e57d Merge pull request #15 from apolukhin/feature/ci-update
CI update: Test on Cygwin, Clang and many other platforms
2018-12-15 00:40:42 +03:00
Antony Polukhin 83e57ed513 Do not run CI tests without RTTI 2018-12-14 12:28:02 +03:00
Antony Polukhin 56393150bb update ci 2018-12-14 11:53:39 +03:00
Antony Polukhin e8d104f34d Merge pull request #14 from gsauthof/verbatim
Add some missing verbatim markers
2018-10-16 22:31:35 +03:00
Georg Sauthoff a770ff87d7 Add some missing verbatim markers
i.e. completed one unbalanced and the rest for some non-verbatim
identifiers.
2018-10-16 21:22:10 +02:00
Antony Polukhin 29997a9fe1 Fix warning
`warning: catching polymorphic type ???class std::bad_cast??? by value`
2018-10-03 20:33:30 +03:00
Antony Polukhin 2a0a2a59f5 Fixed formatting in README and updated the AppveyorCI script 2017-05-20 10:42:53 +03:00
Antony Polukhin 51d544e6b8 Merge pull request #13 from boostorg/danieljames-patch-3
Change the path of the quickbook documentation
2017-03-26 13:09:03 +03:00
Daniel James ee92f4f98b Change the path of the quickbook documentation
The html path is determined by the quickbook id.
2017-03-25 21:50:29 +00:00
Antony Polukhin d46e12c921 Attempt to fix the docs build and redirects 2017-03-25 22:44:56 +03:00
Antony Polukhin 2648b144be Merge pull request #11 from boostorg/danieljames-patch-1
Try to fix the documentation build
2017-03-25 09:31:51 +03:00
Daniel James 32130aa427 Try to fix the documentation build
I think boostdoc is depending on the wrong target. Not sure if this will work, but worth a go?
2017-03-24 09:23:59 +00:00
Antony Polukhin c704762482 Run MinGW tests too (thanks to Pavel Filinov for showing that appveyor apability) 2017-02-23 21:21:50 +03:00
Rene Rivera ae1f2a5cd1 Fix doc build.
The doc building alias reference did not get updated for changed target. This puts in the correct name.
2016-12-27 13:24:04 -06:00
Antony Polukhin 993685b7d0 Merge pull request #10 from very-cool-name/quickbook_doc
Moved documentation from html to Boost Quickbook.
2016-12-26 23:30:40 +04:00
Mike Maximoff eafe2d352e Fixed title to Conversion. 2016-12-25 23:00:40 +03:00
Mike Maximoff 3b9769567e Fixed aliases and copyrights. Created new index.html with redirect only. 2016-12-24 23:13:01 +03:00
Mike Maximoff 610f9fe674 Moved documentation from html to Boost Quickbook. 2016-12-21 23:16:10 +03:00
Antony Polukhin cbe18465d7 Merge pull request #9 from very-cool-name/gcc6_fix
boost::assertion_failed trapped assertions, and subsequent bad casts …
2016-12-17 12:45:02 +04:00
Mike Maximoff 181eb0e6fc boost::assertion_failed trapped assertions, and subsequent bad casts were executed anyway. Now it throws exceptions for assert-like behavior. 2016-12-16 10:46:37 +03:00
Antony Polukhin 46694fb293 Update CI script version 2016-12-04 02:38:30 +03:00
Antony Polukhin 4d814efd3f Update CI scripts, add appveyor CI 2016-12-04 02:35:42 +03:00
Antony Polukhin da8b2fe695 Fix file permissions 2015-12-30 00:08:28 +03:00
Antony Polukhin a7b9f42b9a Use lightweight_test.hpp instead of asserts in tests 2015-12-30 00:07:48 +03:00
Antony Polukhin b6e9403ef0 Fixed warnings in tests 2015-12-14 19:14:28 +03:00
Antony Polukhin 58e8e78899 Run TravisCI tests using valgrind 2015-10-17 17:05:23 +03:00
Antony Polukhin 8f4b6ec985 Fixed issue from track Ticket #11209: conversion - cast_test leaks memory 2015-09-25 19:58:48 +03:00
Antony Polukhin a6100358f4 Add missing include 2015-03-24 22:24:08 +03:00
Antony Polukhin 8f1126f6b2 Merge branch 'alexhenrie-master' into develop 2015-02-03 20:11:03 +03:00
Antony Polukhin b2019fa2df Added a README.md and improved some docs. Added TravicCI integration 2015-02-03 13:28:04 +03:00
Antony Polukhin dc25edb4dd Fixed type deduction on old compilers 2015-02-03 13:00:37 +03:00
Alex Henrie 43ee183296 Correct spelling of "suppress" 2015-01-30 15:22:27 -07:00
Antony Polukhin 84ab59227d Merge pull request #7 from Boris-Rasin/synopsis
fix synopsis for polymorphic_pointer_cast
2014-11-18 19:58:36 +03:00
Boris Rasin 0dc31621c8 fix synopsis for polymorphic_pointer_cast 2014-11-18 14:31:22 +02:00
Antony Polukhin 00b6a53f7e Add polymorphic_pointer_cast 2014-11-10 15:02:20 +04:00
Antony Polukhin 6199649ae2 Move polymorphic_pointer_downcast to a separate header, use pragma once and boost::throw_exception 2014-11-10 14:24:39 +04:00
Antony Polukhin a8253878c8 Merge pull request #6 from Boris-Rasin/polymorphic_pointer_downcast
Add polymorphic_pointer_downcast function template (pull request #2)

Looks really good.
I'll move your implementation into a separate polymorphic_pointer_cast.hpp header to avoid Typeof dependencies for users that do not use `polymorphic_pointer_downcast`
2014-11-10 12:15:34 +03:00
Boris Rasin 582fc91adb add more tests and documentation example for polymorphic_pointer_downcast 2014-11-09 15:37:56 +02:00
Boris Rasin 6a224fa5e9 =add polymorphic_pointer_downcast function template 2014-11-09 00:02:44 +02:00
Antony Polukhin 5d66fea7d5 Merge branch 'master' into develop 2014-08-11 13:19:35 +04:00
Antony Polukhin 4e9021cac5 Merge branch 'develop' 2014-06-16 09:19:29 +04:00
Antony Polukhin ff7ea09a73 remove numeric_cast_test that is a copy of numeric/conversion/test/numeric_cast_test.cpp 2014-06-11 16:23:51 +04:00
Antony Polukhin 6943537150 Drop dependency to the boost_unit_test_framework library in tests 2014-06-11 16:16:40 +04:00
Antony Polukhin cf31a2ec00 Merge pull request #4 from boostorg/pull-request/cast-prune-dependencies
Prune conversion dependencies
2014-06-11 16:03:39 +04:00
Peter Dimov 800c10a4eb Remove use of mpl::identity from implicit_cast.hpp. 2014-06-11 14:45:37 +03:00
Peter Dimov df57f25807 Remove unnecessary includes from cast_test.cpp. 2014-06-11 14:41:55 +03:00
Peter Dimov f0caf56d0b Remove unnecessary includes from implicit_cast_fail.cpp. 2014-06-11 14:40:50 +03:00
Peter Dimov 24d6ac1e87 Remove unnecessary includes from polymorphic_cast.hpp. 2014-06-11 14:38:48 +03:00
Peter Dimov 8a03282736 Add additional tests. 2014-06-11 14:35:27 +03:00
Antony Polukhin 40c42eb740 cast.hpp was moved to the numeric_cast library 2014-06-11 11:44:02 +04:00
Antony Polukhin 36945c35bd Merge branch 'develop' 2014-06-10 13:37:08 +04:00
Antony Polukhin a0922ab598 Remove lexical_cast, add polymorphic_cast.hpp, minor fixes 2014-06-09 12:36:42 +04:00
Antony Polukhin 77a4a55af4 Merge pull request #3 from danieljames/metadata
Add metadata
2014-06-09 11:50:37 +04:00
Antony Polukhin 5c3878f015 Merge pull request #2 from danieljames/link-fix
Fix link to test.
2014-06-09 11:50:19 +04:00
Daniel James 5e93f4086c Remove mention of lexical casts. 2014-06-08 23:42:45 +01:00
Daniel James e2a68fdec1 Add metadata from website 2014-06-08 23:42:19 +01:00
Daniel James ee91295ac4 Fix link to test. 2014-06-08 15:01:02 +01:00
Antony Polukhin e3e4d3836a Merge branch 'develop' 2014-03-14 23:47:58 +04:00
Antony Polukhin d1a51b897d Fix conversions to bool with leading zeros (refs #9659) 2014-03-05 14:48:21 +04:00
Antony Polukhin 9e6aa219d3 Merge branch 'develop' 2014-03-04 16:37:10 +04:00
Antony Polukhin 1e65265b8f Minor fixes in tests 2014-02-11 12:13:17 +04:00
Antony Polukhin 90b4286753 Because of the errors in MSVC with fowarding and static_casting arrays it was decided to drop minor optimization and do not perfect forward source types in try_lexical_convert 2014-02-06 11:22:40 +04:00
Antony Polukhin 5a757dcece Docs updated and minor fixes for MSVC2013 2014-02-04 13:13:33 +04:00
Antony Polukhin 36bc5aea44 Attempt to fix access violation during forwarding of arrays on MSVC 2014-02-03 16:22:27 +04:00
Antony Polukhin ac7da550b4 Attempt to revert incorrectly merged branches 2014-01-19 11:53:50 +04:00
Antony Polukhin e8954f3868 Added docs for try_lexical_convert 2014-01-04 20:26:19 +04:00
Antony Polukhin 1707131ac3 Added some tests for try_lexical_convert and fixed some issues. 2014-01-01 21:47:09 +04:00
Antony Polukhin 2f2c1a3443 Create first merge point for Git 2013-12-30 18:03:42 +04:00
Antony Polukhin 91b77e7373 Do forward input streamable parameter during lexical input streaming. 2013-12-16 19:05:43 +04:00
Antony Polukhin e3dec04dd5 Applied improvements from [boost] [conversion] try_lexical_cast discussion: function is called try_lexical_convert and now uses perfect forwardings when possible. 2013-12-16 18:47:41 +04:00
Antony Polukhin b40bc02f94 try_lexical_cast is now implemented in optimal way 2013-12-13 13:52:18 +04:00
Antony Polukhin 07082420b3 Sketch implementaion of try_lexical_cast 2013-12-12 18:41:51 +04:00
Antony Polukhin 57e4e87e3b Put tests to test folder, remove unrequired files, fix permissions 2013-12-09 11:27:27 +04:00
Antony Polukhin e913b7cb1c Fix some of the implicit conversion warnings (refs #8991)
[SVN r86750]
2013-11-18 11:06:06 +00:00
Antony Polukhin c0c02e560e Attempt to catch libc++ bug with a modified tests
[SVN r86747]
2013-11-18 08:17:33 +00:00
Antony Polukhin bbd746d2ac Slightly modify one of the lexical_cast tests to see what is produced by the to_str method with libc++.
[SVN r86721]
2013-11-16 16:25:26 +00:00
Antony Polukhin bf75439403 Merged a big bunch of internal code changes from trunk for lexical_cast:
dropped support of antique compilers, code changed to produce a smaller binaries and simplify compiler's work, simplified and shortened the code, common with other libraries code moved to 'detail/basic_pointerbuf.hpp' (fixes #9046, fixes #9070, fixes #9271)

[SVN r86654]
2013-11-12 17:15:12 +00:00
Antony Polukhin edde5f442e Another attempt to suppress MSVC warnings (refs #9271)
[SVN r86388]
2013-10-22 09:07:02 +00:00
Antony Polukhin d78d334dbb Add missing #pragma wraning(push) (refs #9271)
[SVN r86378]
2013-10-21 09:21:35 +00:00
Antony Polukhin 39d1abe754 Suppress some of the Level 4 MSVC warnings in the basic_pointerbuf.hpp (refs #9271)
[SVN r86377]
2013-10-21 06:46:01 +00:00
Antony Polukhin 524232ebab Supressing MSVC2013 warnings and ensuring that lexical cast io classes are not copied (refs #9271)
[SVN r86374]
2013-10-20 17:57:15 +00:00
Stephen Kelly 472ebeff30 Simplify multi-component ifdefs containing BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
[SVN r86248]
2013-10-11 23:20:59 +00:00
Stephen Kelly 13f14db751 lexical_cast: Remove obsolete GCC version check.
[SVN r86113]
2013-10-01 08:47:00 +00:00
Stephen Kelly 8a49514506 cast: Remove obsolete MSVC version check.
[SVN r86026]
2013-09-30 00:18:40 +00:00
Stephen Kelly c8bd860de6 Remove obsolete MSVC check from pragma guard
git grep -h -B1 "^#\s*pragma once" | grep -v pragma | sort | uniq

is now clean.

[SVN r85952]
2013-09-26 13:02:51 +00:00
Antony Polukhin a98a74d3dd Merge lexical_casts documentation and tests to release branch (refs #9046)
[SVN r85901]
2013-09-25 13:27:07 +00:00
Antony Polukhin f2e0225b1b Fix generic_stringize example compilation on Darvin (refs #9046)
[SVN r85868]
2013-09-24 14:21:53 +00:00
Antony Polukhin 701963d3c4 lexical_cast.hpp improvements: fix bug with floats conversions and improve docs (refs #9046)
[SVN r85852]
2013-09-23 11:59:06 +00:00
Antony Polukhin ce7a54af7f Minor update of lexical cast before fixing mingw issues (refs #9046)
[SVN r85830]
2013-09-22 16:06:45 +00:00
Antony Polukhin c2c4b884fe Make a separate folder for lexical_casts examples, use those examples in documenation and assure that they successfully build and run (refs #9046)
[SVN r85828]
2013-09-22 12:23:26 +00:00
Antony Polukhin 6f656adea3 Do not treat long long warnings as errors in lexical_cast + containers tests (fixes #9061)
[SVN r85684]
2013-09-15 19:33:17 +00:00
Antony Polukhin c359ed53b2 Fix unused parameter warning (fix #9106)
[SVN r85683]
2013-09-15 19:28:36 +00:00
Antony Polukhin 47041de63a lexical_cast.hpp improvements: interpreter was split to input and output streams to reduce size of binaries and improve compilation times, fixed typo from previous commit (refs #9046)
[SVN r85528]
2013-08-30 14:37:32 +00:00
Antony Polukhin c58a55a512 lexical_cast.hpp improvements: more comments, BOOST_NOEXCEPT and const; parser_buf moved to boost/detail/basic_pointerbuf.hpp, better formatting and simplified type traits (refs #9046)
[SVN r85523]
2013-08-30 08:59:59 +00:00
Antony Polukhin dd165b4b0f lexical_cast.hpp improvements: no more const_casts, much shorter and better template specializations, some code formatting fixes (refs #9046)
[SVN r85513]
2013-08-29 15:35:02 +00:00
Antony Polukhin b5552e351c lexical_cast.hpp improvements: better overflow detections for float conversions, more const modifiers (refs #9046)
[SVN r85512]
2013-08-29 11:41:28 +00:00
Antony Polukhin 297b115e6c lcast_put_unsigned in lexical_cast.hpp header is refactored, duplicate code removed (refs #9046)
[SVN r85499]
2013-08-28 12:55:09 +00:00
Antony Polukhin a2299ec1f9 Fix bug introduced by previous commits during conversion of wide character to wide character. Remove duplicate code and add more comments for lcast_ret_unsigned method. Optimize and simplify overflow detection (refs #9046)
[SVN r85486]
2013-08-27 14:23:19 +00:00
Antony Polukhin bf551ad8c9 Delay character trait extraction (refs #9046)
[SVN r85483]
2013-08-27 07:51:27 +00:00
Antony Polukhin fac805ddf6 Improved some of the metaprogramming methods (refs #9046)
[SVN r85482]
2013-08-27 07:07:15 +00:00
Antony Polukhin 3ce36a2848 Get rid of some macro, improve type traits, fix svn properties, do not supress warnings (refs #9046)
[SVN r85475]
2013-08-26 11:18:42 +00:00
Antony Polukhin 4ba64ea889 Merge from trunk:
* Do not treat critcal errors as bad_lexical_cast exceptions, but if exceptions are on, throw correct exception instead (refs #8966)

[SVN r85331]
2013-08-13 13:08:37 +00:00
Antony Polukhin d723c18fff Update explicit failures markup and lexical_cast_float_types_test.cpp: do not run some checks when libc++ is used, but do expect other checks to pass well.
[SVN r85322]
2013-08-12 16:06:59 +00:00
Antony Polukhin 6bd8edfa02 Do not treat critcal errors as bad_lexical_cast exceptions, but if exceptions are on throw correct exception instead (refs #8966)
[SVN r85232]
2013-08-07 11:08:01 +00:00
Antony Polukhin 7e484c17f6 Merge lexical_cast and some conversion docs and test from trunk:
* fixed int128 and uint128 conversions (fixes #8790)
* fixed warnings from Boost Inspection Report

[SVN r85160]
2013-07-25 16:29:11 +00:00
Antony Polukhin 5f44bdcae8 Fix warnings in lexical_cast found by Boost Inspection program (copyrights restored according to svn history, license text replaced with license name and link to it)
[SVN r85149]
2013-07-24 08:46:08 +00:00
Antony Polukhin a65fcf571f Get rid of BOOST_LCAST_HAS_INT128 macro and use BOOST_HAS_INT128 instead (refs #8790)
[SVN r85073]
2013-07-18 09:13:41 +00:00
Antony Polukhin 13d98f02d0 Fixed testing of 128bit integer types and added staic assert that cheks for std::numeric_limits specializations, if they are required for conversion (refs #8790)
[SVN r85072]
2013-07-18 08:45:09 +00:00
Antony Polukhin 91aa2ce64d Report more warnings while testing boost::lexical_cast. Some warnings suppressed
[SVN r85007]
2013-07-12 11:33:15 +00:00
Antony Polukhin f7bd5e24c2 Fix macro for int128 detection (refs #8790)
[SVN r84965]
2013-07-07 09:51:58 +00:00
Antony Polukhin 3af0af9405 Merge from trunk:
* Fix for GCC-4.8 warning (fixes #8547)
* Disable tests, invalid for C11 (clang specific)

[SVN r84183]
2013-05-07 19:24:47 +00:00
Antony Polukhin c3c44c208a Fix for GCC-4.8 warning (refs #8547)
[SVN r84136]
2013-05-04 12:48:26 +00:00
Antony Polukhin 93a01eba32 Comment out two lexical_cast tests, not actual for C++11
[SVN r83894]
2013-04-14 07:53:45 +00:00
Antony Polukhin b97f2542ec Mrege from trunk:
* Disable UTF16 and UTF32 tests for libc++ (fixes #8369)

[SVN r83764]
2013-04-04 15:47:02 +00:00
Antony Polukhin 12fd711cc8 Disable UTF16 and UTF32 tests for libc++ (refs #8369)
[SVN r83717]
2013-04-02 19:56:49 +00:00
Antony Polukhin 32d70a0764 Merge from trunk:
* Fix stream related issues with libc++ and clang (fixes #7704, fixes #8267)
* Change runtime assert to compile time when converting to pointer (fixes #8267)

[SVN r83689]
2013-04-01 20:40:43 +00:00
Antony Polukhin 1a0ffcadbf Add tests for filesystem::path conversion (refs #7704)
[SVN r83644]
2013-03-30 07:41:23 +00:00
Antony Polukhin ab0727fdac Fix streams and buffers usage (refs #8267 and refs #7704). Now conversions the use STL streams shall work faster
[SVN r83642]
2013-03-30 07:20:22 +00:00
Antony Polukhin 633b852b81 Update code that uses string buffers (refs #8267).
Treat cast to pointer as compile time error (refs #8334).
Update documentation

[SVN r83601]
2013-03-27 17:00:46 +00:00
Antony Polukhin 9fc1a66d27 Reimplement STL string buffer unlocker (refs #8267 and refs #7704)
[SVN r83543]
2013-03-24 15:26:45 +00:00
Antony Polukhin a4bd056b8e Merge from trunk:
* Fixed incorrect usage of Boost.Math when it does not support long double (fixes #8162)
* Fixed ambiguity of boost::lexical_cast functions (fixes #7421)

[SVN r83542]
2013-03-24 14:37:56 +00:00
Antony Polukhin 61938bc8d3 Fix ambiguity while using lexical_cast with std::transform or other functions that may take a pointer to lexical_cast (refs #7421)
[SVN r83457]
2013-03-16 09:24:08 +00:00
Antony Polukhin 694f7b5033 Do not use long double type in lexical_cast for internal variables if Boost.Math has no functions for long double (refs #8162)
Do not test lexical_cast on long doubles, if Boost.Math does not support long double

[SVN r83129]
2013-02-24 13:34:57 +00:00
Antony Polukhin 335c868e9b Merge from trunk:
* Silence some buggy VS warnings (fixes #7949)
* Fix -Wconversion warnings (fixes #2558)
* Added support for int128 conversions (fixes #7909)

[SVN r83114]
2013-02-24 08:31:17 +00:00
Antony Polukhin a15dbed640 Silence some buggy VS warnings (refs #7949)
[SVN r82807]
2013-02-10 13:59:45 +00:00
Antony Polukhin 5c8c897d30 Fixed as many -Wconversion warnings in lexical cast and tests as possible (refs #2558)
[SVN r82695]
2013-02-03 09:20:28 +00:00
Antony Polukhin 3e4a1669f1 More tests (refs #7814)
[SVN r82694]
2013-02-03 07:38:56 +00:00
Antony Polukhin cb9de2c55f Update performance results for VC in docs.
Looks like bug #6523 now is fixed (fixes #6523)

[SVN r82685]
2013-02-02 07:44:09 +00:00
Antony Polukhin 89556c8a0f Documentation update (refs #7909)
[SVN r82561]
2013-01-20 12:20:43 +00:00
Antony Polukhin 47bef9517f Attempt to add support for lexical conversions of int128 types (refs #7909)
[SVN r82560]
2013-01-20 12:13:31 +00:00
Antony Polukhin 518203671c Merge from trunk: fixes #7814 (fixed some numeric to numeric conversions bugs, workaround warnings, -ftrapv now does not triggers coredump)
[SVN r82268]
2012-12-29 14:41:23 +00:00
Antony Polukhin 63b680c082 More strict tests, less workarounds, bugfixes (refs #7814)
[SVN r82227]
2012-12-27 20:17:09 +00:00
Antony Polukhin 16890bf041 Merge from trunk
* Fixes #7799 (optimizations with std::array were not used)
* Fixes #7831 (documentation update)

[SVN r82224]
2012-12-27 18:54:28 +00:00
Antony Polukhin 565e2882d3 Add missing signature to doc (refs #7831)
[SVN r82220]
2012-12-27 18:47:15 +00:00
Antony Polukhin 24bc6ca6f2 Fix bug in array conversion test (refs #7799)
[SVN r82187]
2012-12-23 15:16:01 +00:00
Antony Polukhin 4ad6f1bd4b FIx bug in conversion of some std::array implementations (refs #7799)
[SVN r82172]
2012-12-22 18:42:04 +00:00
Antony Polukhin 5a6309db7a Fix incorrect macro usage (refs #7799)
[SVN r82017]
2012-12-16 09:01:18 +00:00
Antony Polukhin 2333ee53f8 Minor fix in lexical_cast_stream_traits_test.cpp
[SVN r81745]
2012-12-06 17:20:28 +00:00
Antony Polukhin dbda7689e0 Merge lexical_cast from trunk:
* Deduce stream character type for user defined classes (fixes #6786)
* Deprecated macros replaced with new ones (thanks to Marshall Clow)
* Updated documentation (refs #6786, fixes #7582)
* More tests and minor bugfixes

[SVN r81668]
2012-12-02 09:33:42 +00:00
Marshall Clow e15f179bfc Removed usage of deprecated macros
[SVN r81559]
2012-11-26 17:27:53 +00:00
Marshall Clow 82969ebb20 Remove usage of deprecated macros
[SVN r81551]
2012-11-26 14:14:10 +00:00
Antony Polukhin 17f4b6fd4c Comment out some minor unrequired tests
[SVN r81486]
2012-11-22 16:33:54 +00:00
Antony Polukhin 2ea7487806 Move all the stream specific metafunctions to lexical_cast_stream_traits<Source, Target>
Test stream traits for correctness and correct optimization detection

[SVN r81354]
2012-11-15 07:26:23 +00:00
Antony Polukhin cd5a55aab5 Documentation update for lexical_cast (refs #6786)
[SVN r81353]
2012-11-15 06:45:23 +00:00
Antony Polukhin f682bff3a7 Simplify test_getting_pointer_to_function to don't deal with compilers bugs and just test that getting pointer to lexical_cast<T1, T2> is not ambiguous
[SVN r81294]
2012-11-11 08:59:36 +00:00
Antony Polukhin 1c37887f2b Stream type detection metafunctions were rewritten so that now they can detect stream type for user defined types (refs #6786)
Removed unrequired `::` 

[SVN r81278]
2012-11-10 07:42:04 +00:00
Antony Polukhin 5c3159cd1c Attempt to workaround VACPP, CRAY and ancient GCC bugs in lexical_cast tests
[SVN r81162]
2012-11-03 16:20:43 +00:00
Antony Polukhin c484325310 Fix FAQ section of lexical_cast documentation (refs #7582)
[SVN r81069]
2012-10-27 16:30:41 +00:00
Antony Polukhin 0920c53e23 Merege fix for #7421 from trunk
[SVN r80787]
2012-09-30 16:07:32 +00:00
Antony Polukhin 42e7585dd4 Tiny documentation update (refs #7421)
[SVN r80739]
2012-09-28 18:31:53 +00:00
Antony Polukhin 7b6c4eed7d Remove bad test (refs #7421)
[SVN r80731]
2012-09-28 04:55:37 +00:00
Antony Polukhin 824fbd9b06 Do not overload lexical_cast<To, From>(const From&), instead add lexical_cast<To>(character_type,size_type) templates (refs #7421). Added tests for getting &boost::lexical_cast<To,from> functions pointers
[SVN r80715]
2012-09-26 19:57:31 +00:00
Antony Polukhin 8d373a0c99 Merge updated tests from trunk (now float types tests are less strict, workaround MSVC2012 bug)
[SVN r80672]
2012-09-23 17:19:05 +00:00
Antony Polukhin 77eff6b47d Workaround MSVC2012 error in lexical_cast_test.cpp
[SVN r80584]
2012-09-18 20:11:05 +00:00
Antony Polukhin 8705038cd2 Workaround MSVC2012 error in lexical_cast_test.cpp
[SVN r80503]
2012-09-12 03:58:26 +00:00
Antony Polukhin bb224866a7 Fix float types tests, make them less strict (so that MSVC2012 could pass it)
[SVN r80438]
2012-09-08 01:44:18 +00:00
Antony Polukhin 733438e072 Merge from trunk:
1) #warning replaced with #error (refs #7228)
2) Pavel Korzh added to thanks list (refs #7157)
3) BOOST_NOEXCEPT modifiers added where possible
4) better support for c++11 Unicode characters
5) fixed compilation with MSVC+STLPort
6) more agressive usage of Traits template parameter
7) Added lexical_cast(const CharType* chars, std::size_t count) function overload (refs #6430 and refs #6663)
8) Fixed GCC warning in numeric_cast_test.cpp
9) Fix compilation of lexical cast with MSVC 2003 (refs #7255)

[SVN r80409]
2012-09-05 18:23:41 +00:00
Antony Polukhin c43b86d7f1 Replace .c_str() with .data() in documentation (refs #6663)
[SVN r80377]
2012-09-03 17:23:16 +00:00
Antony Polukhin c290a26625 Added missing const modifier
[SVN r80374]
2012-09-03 17:06:40 +00:00
Antony Polukhin d08477900d Added lexical_cast(const CharType* chars, std::size_t count) function overload (refs #6430 and refs #6663)
Fixed GCC warning in numeric_cast_test.cpp

[SVN r80291]
2012-08-28 20:31:16 +00:00
Antony Polukhin 63acf4f174 Fix compilation of lexical cast with MSVC 2003 (refs #7255)
[SVN r80210]
2012-08-25 19:07:46 +00:00
Antony Polukhin ce95319f03 Multiple small changes:
1) #warning replaced with #error (refs 7228)
2) Pavel Korzh added to thanks list (refs 7157)
3) BOOST_NOEXCEPT modifiers added where possible
4) better support for c++11 Unicode characters
5) fixed compilation with MSVC+STLPort
6) more agressive usage of Traits template parameter

[SVN r80105]
2012-08-21 04:44:00 +00:00
Antony Polukhin f67347e308 Merge bugfix for volatile types (refs #7157)
[SVN r79871]
2012-08-05 09:46:43 +00:00
Antony Polukhin d6a72e9ea5 Fix bug with volatile types (refs #7157)
[SVN r79797]
2012-07-29 18:54:24 +00:00
Antony Polukhin 46c6cc911b Merge fix of VC warning (fixes #7116)
[SVN r79605]
2012-07-19 18:42:34 +00:00
Antony Polukhin 3c94791b1e Workaround VC warning (refs #7116)
[SVN r79565]
2012-07-16 17:17:00 +00:00
Antony Polukhin 80d480ca0b Fix typo in documentation (fixes #7129)
[SVN r79480]
2012-07-13 19:22:49 +00:00
Antony Polukhin e81d4dfdbb Fix typo in documentation (fixes #7129)
[SVN r79479]
2012-07-13 19:20:05 +00:00
Antony Polukhin 675d0bb451 Merge from trunk (now lexical_cast has optimized conversions to and from array<>, fixes #7065)
[SVN r79364]
2012-07-08 18:06:32 +00:00
Antony Polukhin fe79553bf8 Fix tab in documentation (refs #7065)
[SVN r79363]
2012-07-08 17:59:50 +00:00
Antony Polukhin 093e298c9d Updated documentaion and performance test (now we have info about conversion speed to and from array<>, refs #7065)
[SVN r79297]
2012-07-05 19:27:35 +00:00
Antony Polukhin d2361fe05a Updated documentaion, fixed bug and refactored tests (refs #7065)
[SVN r79266]
2012-07-04 18:50:56 +00:00
Antony Polukhin b037563bf9 Documentation update: documented optimizations for boost and std arrays (refs #7065)
[SVN r79249]
2012-07-03 17:32:29 +00:00
Antony Polukhin 88244b57d4 Split lexical_cast_test.cpp into two tests and reduce iterations count for integral types tests (now we must not exceed tests timeouts)
[SVN r79246]
2012-07-03 17:10:02 +00:00
Antony Polukhin e3cd0ca7fa Optimizations for boost and std array (refs #7065)
[SVN r79230]
2012-07-02 18:30:21 +00:00
Antony Polukhin 79d6468aeb Merge lexical_cast from trunk :
* force SunCC compiler to use fallback version of lexical_cast (with fallbak version SunCC can pass at least some tests)
* removed trailing whitespaces

[SVN r78565]
2012-05-24 04:22:04 +00:00
Antony Polukhin c6318e3819 Do not force PGI compiler to use fallback version of lexical_cast (PGI fails tests even in fallback version)
Trialing whitespaces removed

[SVN r78521]
2012-05-20 16:25:21 +00:00
Antony Polukhin e691b15b77 Force PGI and SunCC compillers to use fallback version of lexical_cast
[SVN r78485]
2012-05-15 18:51:35 +00:00
Antony Polukhin ca9c8d30bd Merge from trunk:
* Fixes ISO C++ does not support the ‘%lg’ gnu_printf format (refs #6852)
* explicit-failures-markup merge from trunk
* supress warnings in implicit_cast.cpp test

[SVN r78450]
2012-05-13 08:15:51 +00:00
Antony Polukhin bb46dbc46c Fixes #6852 for wide characters (ISO C++ does not support the ‘%lg’ gnu_printf format fixed)
[SVN r78408]
2012-05-10 17:39:46 +00:00
Antony Polukhin d30dd9e3c8 Fixes #6852 (ISO C++ does not support the ‘%lg’ gnu_printf format fixed)
[SVN r78308]
2012-05-02 19:00:37 +00:00
Antony Polukhin b1b5305984 Merge from trunk:
* fixed #6812 (now converting "." to float type throws bad_lexical_cast)

[SVN r78211]
2012-04-26 17:59:17 +00:00
Antony Polukhin 15ab0d6385 Fixes #6812 (now converting "." to float type throws bad_lexical_cast)
[SVN r78111]
2012-04-21 11:08:03 +00:00
Antony Polukhin eb4ad73caf Merge lexical_cast library from trunk:
* multiple optimizations and bugfixes for boost::iterator_range (refs #6786, refs #6430, refs #6663)
* documentation update
* new Unicode characters support updated
* much more tests, removed incorrect tests

[SVN r78059]
2012-04-18 04:09:49 +00:00
Antony Polukhin d963842d70 Typo fix in documentation. New line added to the end of lexical_cast.hpp file
[SVN r78051]
2012-04-17 18:00:30 +00:00
Antony Polukhin 9ff79f4df9 Update documentation ( more info about stream character type detection + warn about new unicode types support; refs #6786, refs #6663)
[SVN r78044]
2012-04-17 16:27:50 +00:00
Antony Polukhin 746d466e38 Comment out bad advise in documentation ( refs #6786, refs #6663)
[SVN r78015]
2012-04-16 17:13:11 +00:00
Antony Polukhin 674e71fb7d Fix compile time error in lexical_cast, when new unicode characters are being converted (Refs #6504 )
[SVN r77936]
2012-04-12 17:15:22 +00:00
Antony Polukhin 35d592fc21 Fix iterator_range test for compilers with new unicode characters but without new unicode locales support
[SVN r77921]
2012-04-11 18:34:10 +00:00
Antony Polukhin 7881eb5666 Remove incorrect test
[SVN r77854]
2012-04-09 18:07:51 +00:00
Antony Polukhin 8562b480f8 * fixes #6504 (characters widening fixed)
* much more tests
* better support for unicode characters and template classes that are instantinated with unicode character types
* meta code refactored (it is now shorter and clearer)

[SVN r77824]
2012-04-07 19:44:07 +00:00
Antony Polukhin 6ff6958204 Removed incorrect test
[SVN r77807]
2012-04-07 08:05:16 +00:00
Antony Polukhin 1e58331baf Merge lexical_cast from trunk:
* fixed #6717 (now lexical_cast won`t try to support non confirming swprintf)
* fixed #6670 (now using BOOST_NO_UNICODE_LITERALS macro to detect unicode literals support)
* rewritten Jamfile

[SVN r77804]
2012-04-07 07:52:23 +00:00
Antony Polukhin 2af8c47558 Fix inspection warning (tab removed)
[SVN r77773]
2012-04-05 03:59:02 +00:00
Antony Polukhin deef894ae2 Lexical_cast test's Jamfile has been rewritten (boost license is now explicitly defined, disabled build of typedefed_wchar_runtime for unsupported targets, nicer and more compact jamfile instructions)
[SVN r77772]
2012-04-05 03:53:58 +00:00
Antony Polukhin 4a617adce1 More workarounds for fixed #6670 (disable more char16_t and char32_t tests for some compilers)
[SVN r77745]
2012-04-03 18:00:30 +00:00
Antony Polukhin 969a913153 More workarounds for fixed #6670 (disable basic char16_t and char32_t tests for some compilers, disable optimizations for them)
[SVN r77721]
2012-04-02 16:58:32 +00:00
Antony Polukhin 41a673db61 Fixes #6717 (now also setting precision for float types conversion when using iostreams)
[SVN r77716]
2012-04-02 15:33:46 +00:00
Antony Polukhin acb746274f Fixes #6670 (now using BOOST_NO_UNICODE_LITERALS macro)
[SVN r77691]
2012-04-01 19:08:46 +00:00
Antony Polukhin dfb518997f Fixes #6717 (now lexical_cast won`t try to support non confirming swprintf)
[SVN r77639]
2012-03-30 03:55:26 +00:00
Antony Polukhin 93ee01ab69 Merge from trunk r77627 (merged lexical_cast optimizations for iterator_range<>, fixed performance regression, docs updated)
[SVN r77628]
2012-03-29 16:48:31 +00:00
Antony Polukhin 4265f454e1 Small documentation updates for #6663
[SVN r77537]
2012-03-25 05:31:43 +00:00
Antony Polukhin 76b9f29c12 Fixes #6663 (much more optimizations for iterator_range, updated documentation and performance test results)
[SVN r77517]
2012-03-24 19:35:19 +00:00
Antony Polukhin a065884c59 Merge from trunk
* Much more tests
* Now numeric_cast (and lexical_cast) can be compiled with disabled exceptions
* Supress warning described in #6645 (implicit conversion shortens 64-bit value into a 32-bit value)
* Fixed compilation of lexical_cast with BOOST_NO_STD_LOCALE defined
* Documentation updates
* Case insensitive "NaN" and "Inf" parsing 
* Performance tests commit

[SVN r77288]
2012-03-10 07:31:36 +00:00
Antony Polukhin 676bde6e1f More strict tests for disabled exceptions (for fixed #5800)
[SVN r77236]
2012-03-05 18:44:31 +00:00
Antony Polukhin 7e7f494dd1 Attempt to supress warning described in #6645 (implicit conversion shortens 64-bit value into a 32-bit value)
[SVN r77221]
2012-03-04 17:59:03 +00:00
Antony Polukhin 83639bd9ae Fixes #6571 (documentation update, added 'why lexical_cast does not understand "-1.#IND"' question and answer to it)
[SVN r77118]
2012-02-26 09:19:55 +00:00
Antony Polukhin 0dded6d3a7 Update for fixed #6441 (unable to compile lexical_cast with BOOST_NO_STD_LOCALE defined)
Now test must compile under VC, removed some warnings.

[SVN r77117]
2012-02-25 17:32:26 +00:00
Antony Polukhin 25d880f5eb Updates #5800 (partially fix lexical cast compilation with disabled exceptions)
[SVN r77116]
2012-02-25 16:58:46 +00:00
Antony Polukhin b71fb9aada Fixes #6441 (compilation error with BOOST_NO_STD_LOCALE defined)
[SVN r77077]
2012-02-20 16:20:09 +00:00
Antony Polukhin d9baa71302 Updated INF/NAN support for char16_t and char32_t
[SVN r77058]
2012-02-17 18:51:05 +00:00
Antony Polukhin 80e858b182 More tests for fixed #5689 (issue mentiond in 5th comment)
[SVN r77040]
2012-02-16 17:57:52 +00:00
Antony Polukhin 646b958a92 FIx #5689 (issue from 5th comment)
[SVN r77039]
2012-02-16 17:56:27 +00:00
Antony Polukhin 04f441e989 Commited sources of performance testing program and Jamfile.v2 to build and run it
[SVN r76936]
2012-02-07 17:20:03 +00:00
Antony Polukhin e51cf081b3 Merge from trunk (fixed #6251, fixed #6453, disabled some optimizations for sunCC #6462)
[SVN r76887]
2012-02-04 18:04:45 +00:00
Antony Polukhin 7a48fea517 Disabling some optimisations for sun cc
Bug described in #6462

[SVN r76824]
2012-02-01 17:08:10 +00:00
Antony Polukhin c9863cd254 FIxes #6453 (compile error due to deduce_char_traits ambiguity)
[SVN r76818]
2012-02-01 04:25:21 +00:00
Antony Polukhin 132663404b Added tests for ticket #6453
[SVN r76817]
2012-02-01 04:22:21 +00:00
Antony Polukhin a0cbfa8af6 New test case from ticket #5793
[SVN r76809]
2012-01-31 16:05:22 +00:00
Antony Polukhin efe20fcf76 Tiny change to test case from #6452
[SVN r76708]
2012-01-26 17:51:17 +00:00
Antony Polukhin 84d9706182 Update tests with example from #6452
[SVN r76707]
2012-01-26 17:47:56 +00:00
Antony Polukhin 5ed7bfd280 Attempt to fix #6251
[SVN r76599]
2012-01-20 19:33:04 +00:00
Antony Polukhin 51a6aacb57 Merge from trunk r76357
(tiny documentation update)

[SVN r76358]
2012-01-08 09:25:04 +00:00
Antony Polukhin 7bdc45327a Tiny documentation update
[SVN r76356]
2012-01-08 09:21:00 +00:00
Antony Polukhin a2e4606e6c Merge from trunk r76354
(Fixes overflow detection, pointers casts)

[SVN r76355]
2012-01-08 09:05:35 +00:00
Antony Polukhin 9a6d983ee5 Fixes #6193
[SVN r76318]
2012-01-05 12:09:15 +00:00
Antony Polukhin d754143308 Fixes #6132
Fixes #6182

[SVN r76305]
2012-01-04 16:06:37 +00:00
Antony Polukhin 82abf7b54f Merge from trunk r76232
[SVN r76233]
2011-12-30 15:18:00 +00:00
Antony Polukhin 085bd6f93c Fixes #6290
Tiny documentation update
Updated char16_t and char32_t support (still some work required)
lexical_cast_empty_input_test.cpp refactored 

[SVN r76154]
2011-12-25 18:55:33 +00:00
Antony Polukhin 5d288580ee Fixes #6298
Fixes #6264

[SVN r76096]
2011-12-21 17:03:52 +00:00
Antony Polukhin 7112ded1b9 Merge from trunk r75937
* fixed a lot of wchar_t errors
* Optimizations for boost::containers::basic_string
* More tests

[SVN r76062]
2011-12-19 15:19:43 +00:00
Antony Polukhin 8627f8bb8a Fixes #6186 (treat conversions to/from single wchar_t character as conversions to/from unsigned short. Test added, documentation updated)
[SVN r75937]
2011-12-14 16:36:34 +00:00
Antony Polukhin f32fb4b5e5 Fixes #6186 test failures
[SVN r75921]
2011-12-12 18:09:53 +00:00
Antony Polukhin a9697b88fd Fixes #6186 (lexical_cast compliation error fixed, when wchar_t is a typedef for unsigned short. Test added)
[SVN r75864]
2011-12-08 15:29:44 +00:00
Antony Polukhin 2312691bde Fixes #6127 (wchar_t usage outside of #ifndef BOOST_LCAST_NO_WCHAR_T )
[SVN r75813]
2011-12-05 16:29:45 +00:00
Antony Polukhin 7dd63d08d6 Fixes #6159 (compilation on platforms without cwchar)
[SVN r75812]
2011-12-05 16:17:09 +00:00
Antony Polukhin 1eda87448e Fixes #6083
Merge from trunk

[SVN r75411]
2011-11-08 18:12:23 +00:00
Antony Polukhin 4ddb0bfb95 Fix for error noticed by Olaf van der Spek (ticket #6083)
Added test case for that error

[SVN r75283]
2011-11-03 04:33:58 +00:00
Antony Polukhin c07cbcee5c Performance optimizations and testsfor conversions to/from boost::container::basic_string
[SVN r74940]
2011-10-13 18:36:39 +00:00
Gennadiy Rozental 8c7c7b9237 eliminated unit_test_framework and BOOST_MESSAGE
[SVN r74727]
2011-10-05 09:42:21 +00:00
Gennadiy Rozental 3d60698843 eliminated unit_test_framework
[SVN r74720]
2011-10-05 09:15:12 +00:00
Antony Polukhin 3a62368d0e Merge from trunk r74564
* char16_t and char32_t conversions now work on gcc for C locale
* Optimizations for C locale
* Performance section of documentation updated

[SVN r74565]
2011-09-25 16:44:39 +00:00
Antony Polukhin d2ae7fdbd7 char16_t and char32_t conversions now work on gcc for C locale
Optimizations for C locale
Performance section of documentation updated

[SVN r74432]
2011-09-17 09:09:27 +00:00
Antony Polukhin e1caac418c Mereged from r74355
Basic support for char16_t and char32_t

[SVN r74361]
2011-09-12 18:15:31 +00:00
Antony Polukhin 2acef7aa44 Basic support for char16_t and char32_t
[SVN r74243]
2011-09-05 19:00:29 +00:00
Antony Polukhin 8480a6d083 Merge from trunk r73850
* Documentation commited

[SVN r73852]
2011-08-17 18:44:00 +00:00
Antony Polukhin 00f1246faf Merge from trunk r73850
* Compile time optimizations
* Float types optimizations
* Source code refactoring
* Parsing and writing inf and nan values according to the standart
* Fixed some bugs and warnings
* New tests
* New documentation

[SVN r73851]
2011-08-17 18:43:10 +00:00
Antony Polukhin 2f5d0c847b Fixes #5783
Fixes ambiguities with operators >> and <<. Adds tests for such cases.

[SVN r73818]
2011-08-16 17:09:25 +00:00
Antony Polukhin eb66b40e67 FIxes #5631
Workaround for nvcc bug

[SVN r73707]
2011-08-12 17:35:56 +00:00
Antony Polukhin 5ebb13bbad Very small update for FAQ section of documentation
[SVN r73706]
2011-08-12 17:08:17 +00:00
Antony Polukhin 4a4150d0be Fixes #5746
Updates FAQ section of documentation

[SVN r73705]
2011-08-12 17:04:31 +00:00
Antony Polukhin 9955dcce51 Fixes #5732.
* suppress compilation warnings, if the compiler requires a return, even when it can never be reached

[SVN r73640]
2011-08-10 18:58:06 +00:00
Antony Polukhin e8108e5066 Fixes #5732.
* some fixes for WinCE
* updated explicit failures markup

[SVN r73601]
2011-08-07 17:38:33 +00:00
Antony Polukhin a9778ad460 Fixes #5732.
* at least compiles on pgi

[SVN r73446]
2011-07-30 16:47:30 +00:00
Antony Polukhin aba423d425 Fixes #5732.
* one more try to fix compilation errors on pgi compiler 

[SVN r73435]
2011-07-29 19:33:18 +00:00
Antony Polukhin 30e4efd062 Fixes #5732.
* one more try to fix compilation errors on pgi compiler 

[SVN r73401]
2011-07-27 15:56:49 +00:00
Antony Polukhin 19f316f768 Fixes #5732.
* fixes compilation errors pgi compiler 
* fixes some bugs for MinGW compiler

[SVN r73384]
2011-07-26 18:51:39 +00:00
Antony Polukhin 9ac4e2bef1 Fixes #5732.
* fixes compilation errors for nonconst char arrays

[SVN r73357]
2011-07-25 15:13:36 +00:00
Antony Polukhin 2b76f558c1 #5732. Adds workaround for MinGW bugs
[SVN r73347]
2011-07-25 05:02:07 +00:00
Antony Polukhin 0ee6400d5e Fixes #5732.
* fixes some warnings and bugs for VC

[SVN r73328]
2011-07-24 10:56:54 +00:00
Antony Polukhin fd264b0583 Fixes #5732.
* fixes performance regression, that was added by previous commit
* fixes float types preformance regression for old compilers

[SVN r73323]
2011-07-24 09:42:06 +00:00
Antony Polukhin 8a756eae7b Fixes #5732.
* reduces templates count
 * leaves only one lexical converting class (at least for modern compilers)
 * fixes small TODOs and XXXs from source code
 * makes lexical_stream_limited_src more readable
 * updates status/explicit-failures-markup.xml
 * makes lexical_cast_inf_nan_test.cpp pass on Itanium pltform
 * makes lexical_cast able to convert signed and unsigned chars to wchar_t
 and updates lexical_cast_wchars_test

[SVN r73313]
2011-07-23 15:55:54 +00:00
Antony Polukhin c1c8485cb4 Fixes #5723. Links in documentation are now implemented via [@boost: ]
[SVN r73277]
2011-07-21 15:35:11 +00:00
Antony Polukhin c372f482a2 Fixes #5723. Fixes broken link
[SVN r73269]
2011-07-21 08:20:35 +00:00
Daniel James fa7f4ba7a7 Link up the new lexical cast documentation.
[SVN r73267]
2011-07-21 07:35:29 +00:00
Antony Polukhin 272e92ba7f Fixes #5723. Updates lexical_cast maintainer info
[SVN r73256]
2011-07-20 11:50:46 +00:00
Antony Polukhin c6c501c769 Fixes #5689. Added code to work -NaN on any platform. Removed some warnings
[SVN r73155]
2011-07-16 21:02:32 +00:00
Antony Polukhin de3df54f80 Fixes #5689. Added code to work with Inf and NaN on any platform
[SVN r73118]
2011-07-15 11:20:11 +00:00
Antony Polukhin 27a7fac22e Updates #5660.
Removed duplicate tests.
Unified behaviour for float conversions on different compillers

[SVN r72972]
2011-07-08 17:23:31 +00:00
Antony Polukhin fff0066392 Fixes #5676.
Tests for float types are now more accurate

[SVN r72955]
2011-07-07 16:04:32 +00:00
Antony Polukhin 0e2235dc75 Fixes #5675. Adds tests on #5675.
Updates #5660. Updates performance section of documentation

[SVN r72954]
2011-07-07 11:31:25 +00:00
Antony Polukhin 6a8c22d5c3 Partial fix for #5660. Better performance and less memory usage for conversions to float type (and to double type, if sizeof(double) < sizeof(long double)). New test suits. Documentation update.
[SVN r72925]
2011-07-06 15:43:04 +00:00
Antony Polukhin 6c5f31e7a5 lexical-cast mereged from trunk r72347 (allow "C" locale grouping for other locales)
[SVN r72348]
2011-06-02 16:20:36 +00:00
Antony Polukhin cd0167d6b8 Fixes #5585 and adds test on it
[SVN r72315]
2011-05-31 20:46:37 +00:00
Antony Polukhin 1f7147d24b mereged lexical_cast from trunk r72267 (more optimizations, updated documentation, added tests)
[SVN r72268]
2011-05-29 19:21:28 +00:00
Antony Polukhin ccaa3059e8 Improved english and documentation design for #5576.
[SVN r72225]
2011-05-27 18:32:57 +00:00
Antony Polukhin b0b1ce9453 Fixes #5576, adds performance section to the lexical_cast documentation, fixes misprint in tests/
[SVN r72224]
2011-05-27 18:19:38 +00:00
Antony Polukhin 98d24e04f4 Fixes #5564. Adds tests on #5564 and more tests on #5557
[SVN r72203]
2011-05-27 04:22:18 +00:00
Antony Polukhin a385c3ec99 Merge from trunk: r72184 (a lot of optimizations, new tests, fix inspection warnings).
[SVN r72185]
2011-05-26 16:27:53 +00:00
Antony Polukhin 920e36f6ba Fixes #5557. Adds tests on #5557
[SVN r72071]
2011-05-22 11:35:00 +00:00
Antony Polukhin dc9b364d6f Fixes #5417. Much better performance on casts to integral types.
Adds more tests for overflow detection.
Workaround for bugs of vc8 (lexical_cast_vc8_bug_test.cpp now passes)
Fixes some inspection errors.

[SVN r72056]
2011-05-20 17:11:53 +00:00
Antony Polukhin 95360b5df6 Fixes #5417. Fixes #4397
More tests (for conversions to float types, for conversions of negative values to unsigned integers)

[SVN r71958]
2011-05-15 15:31:01 +00:00
Antony Polukhin 701d5f0bf0 Merged from trunk revision 71922. Most part of this modifications of lexical_cast library were made and successfully tested during the year 2009.
Later commits affected only documentation bugs.

[SVN r71923]
2011-05-13 17:44:51 +00:00
Antony Polukhin 266ebbcb88 Added documentation on the feature, described in ticket. Fixed 5494
[SVN r71922]
2011-05-13 17:31:16 +00:00
Antony Polukhin e41ef929d2 FIx #5536
[SVN r71901]
2011-05-12 17:21:07 +00:00
Alexander Nasonov c28efea0b3 Fix an access to grouping[grouping.size()].
AFAIK, this is valid for const strings but STLport (when _STLP_DEBUG
is defined) doesn't like it.
The problem reported by Bogdan Dragu.


[SVN r65279]
2010-09-05 00:02:25 +00:00
Steven Watanabe 00b609b498 Supress MSVC /Wp64 warnings. Fixes #4184
[SVN r62806]
2010-06-11 16:12:39 +00:00
Alexander Nasonov 2cfa78ab40 Apply the patch from #4119. Fixes #4119.
[SVN r62529]
2010-06-07 22:58:42 +00:00
Daniel James b5583b88fa Merge some detail changes.
- [53670] Avoid C style casts.
 - [55604] Fix #3346 boost/detail/scoped_enum_emulation.hpp enum_t conflict
   with Unix rpc/types.h
 - Don't foward declare containers when using gcc's parallel library and add a
   macro to disable forward declaration. Fixes #3866.


[SVN r59679]
2010-02-14 16:31:21 +00:00
Alexander Nasonov 5c1dc5388c Use BOOST_LCAST_THROW_BAD_CAST consistently.
[SVN r59664]
2010-02-13 01:24:34 +00:00
John Maddock fce9ad4e1b Misc small fixes to suppress warnings.
Code should now be clean with msvc /W4 and gcc /Wall /Wextra -pedantic with the exception of one deliberate warning in one test.

[SVN r57510]
2009-11-09 12:27:54 +00:00
Troy D. Straszheim febafb7cb8 rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back
[SVN r56942]
2009-10-17 02:07:38 +00:00
Troy D. Straszheim 5b6e39b2b8 rm cmake from the release branch before it goes out broken. Policy dictates that you never commit to release, you commit to trunk and merge to release.
[SVN r56941]
2009-10-17 01:10:45 +00:00
Alexander Nasonov f5d825e77f Decrease indent of #if and #endif lines and test string<->integral conversons when BOOST_NO_INTRINSIC_WCHAR_T is defined.
[SVN r56232]
2009-09-15 23:56:39 +00:00
Alexander Nasonov 04f73e5a89 Decrease indent of #if and #endif lines and test string<->integral conversons when BOOST_NO_INTRINSIC_WCHAR_T is defined.
[SVN r56231]
2009-09-15 23:55:47 +00:00
Alexander Nasonov 65328d9716 Add new test libs/conversion/test/lexical_cast_vc8_bug_test.cpp.
[SVN r56230]
2009-09-15 23:41:02 +00:00
Alexander Nasonov 79a141ce9d Add new test libs/conversion/test/lexical_cast_vc8_bug_test.cpp.
[SVN r56229]
2009-09-15 23:38:21 +00:00
Alexander Nasonov 78adbeaab1 DISABLE_WIDE_CHAR_SUPPORT -> BOOST_LCAST_NO_WCHAR_T.
[SVN r56228]
2009-09-15 22:55:02 +00:00
Alexander Nasonov dc151d2b5a DISABLE_WIDE_CHAR_SUPPORT -> BOOST_LCAST_NO_WCHAR_T.
[SVN r56227]
2009-09-15 22:53:27 +00:00
Alexander Nasonov 23949682c1 [lexical_cast] Merge from trunk r56170 (#2295 Inconsistent behavior when using 64 bit integer types) and r56171 (Add a test for uintmax_t).
[SVN r56172]
2009-09-13 15:03:52 +00:00
Alexander Nasonov 0aaa89042a Add a test for uintmax_t.
[SVN r56171]
2009-09-13 14:58:34 +00:00
Alexander Nasonov b37f56f478 Fix #2295 (Inconsistent behavior when using 64 bit integer types).
[SVN r56170]
2009-09-13 14:48:27 +00:00
Alexander Nasonov 5055e842cf Merge from trunk r56160 (Can't compile without <locale> header, boost::lexical_cast problem).
[SVN r56161]
2009-09-12 22:24:35 +00:00
Alexander Nasonov c22d671409 Fix #1847 (Can't compile without <locale> header, boost::lexical_cast problem).
[SVN r56160]
2009-09-12 22:22:28 +00:00
Alexander Nasonov 9e764f3e49 [lexical_cast] Merge from trunk: r56158 (fix warning on MSVC warning level 4) and r53668 (avoid C style casts).
[SVN r56159]
2009-09-12 22:11:01 +00:00
Alexander Nasonov 8582e25571 Fix #1791 (fix warning on MSVC warning level 4) and undo r34801 (some "rewording" to avoid spurious level 4 warnings with VC7.1 and VC8).
[SVN r56158]
2009-09-12 21:47:27 +00:00
Troy D. Straszheim a77fc4c0bb Copyrights on CMakeLists.txt to keep them from clogging up the inspect
reports.  This is essentially the same commit as r55095 on the release
branch.



[SVN r55159]
2009-07-26 00:49:56 +00:00
Troy D. Straszheim a3e690da32 Add basic copyright/license to keep cmake out of the inspection report
[SVN r55095]
2009-07-22 21:51:01 +00:00
Gennadiy Rozental 7b37688ca8 avoid C style casts
[SVN r53670]
2009-06-06 09:41:03 +00:00
Gennadiy Rozental fa4a95c1dd avoid C style casts
[SVN r53668]
2009-06-06 09:38:47 +00:00
Troy D. Straszheim fb681bb0ea merge of cmake build files from trunk per beman
[SVN r50756]
2009-01-24 18:57:20 +00:00
Alexander Nasonov 98a67d93f3 Fixes #1220: lexical_cast requires RTTI
[SVN r50124]
2008-12-04 23:18:50 +00:00
Alexander Nasonov 5fa1edeee0 Fixes #1220: lexical_cast requires RTTI
[SVN r50123]
2008-12-04 22:59:27 +00:00
Michael A. Jackson b72cb10ae6 Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use.
[SVN r49627]
2008-11-07 17:02:56 +00:00
Michael A. Jackson 4217a354f5 Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor
[SVN r49510]
2008-11-01 13:15:41 +00:00
Alexander Nasonov 0c54d6a037 Merge lexical_cast from trunk r49262
[SVN r49325]
2008-10-13 23:54:01 +00:00
Alexander Nasonov 6c5fd3e86d Fix #2184 (Macro without BOOST_ prefix)
[SVN r49262]
2008-10-10 23:16:10 +00:00
Alexander Nasonov 2296357eaf Fix #2299 (Patch to fix warnings in lexical_cast)
[SVN r49261]
2008-10-10 22:56:08 +00:00
Daniel James 39329bc5b9 Merge quickbook workaround and fix some links.
Merged revisions 48987,49230-49231 via svnmerge from 
https://svn.boost.org/svn/boost/trunk

........
  r48987 | danieljames | 2008-09-28 13:21:39 +0100 (Sun, 28 Sep 2008) | 1 line
  
  Clean up some link errors.
........
  r49230 | danieljames | 2008-10-09 23:13:48 +0100 (Thu, 09 Oct 2008) | 1 line
  
  position_iterator is meant to be a forward iterator, so avoid using operator+ with it.
........
  r49231 | danieljames | 2008-10-09 23:14:14 +0100 (Thu, 09 Oct 2008) | 4 lines
  
  Work around the problems with window newlines in position_iterator. (I'm
  about to fix them, but this will get quickbook working immediately).
  
  Fixes #2155
........


[SVN r49242]
2008-10-10 09:29:21 +00:00
Nicola Musatti 33981b9400 Patch from Ticket #2370
[SVN r49154]
2008-10-06 20:22:10 +00:00
Daniel James 2708853971 Clean up some link errors.
[SVN r48987]
2008-09-28 12:21:39 +00:00
Daniel James 2ce20c872e Fix link to numeric conversion library
Merged revisions 48003 via svnmerge from 
https://svn.boost.org/svn/boost/trunk

........
  r48003 | danieljames | 2008-08-06 16:28:17 +0100 (Wed, 06 Aug 2008) | 1 line
  
  Fix link to numeric conversion library.
........


[SVN r48026]
2008-08-07 22:12:31 +00:00
Daniel James ae273a3e7b Fix link to numeric conversion library.
[SVN r48003]
2008-08-06 15:28:17 +00:00
Peter Dimov 0d258ff7b1 Largely pointless Borland 5.5.1 changes. :-)
[SVN r45627]
2008-05-21 21:13:22 +00:00
Alexander Nasonov ae5cbbbec8 Fixes #1847 Can't compile without <locale> header, boost::lexical_cast problem
[SVN r45201]
2008-05-07 19:43:55 +00:00
Alexander Nasonov e1dbc6ef04 Use make_unsigned and get rid of gcc warnings when -DBOOST_LEXICAL_CAST_ASSUME_C_LOCALE
[SVN r44474]
2008-04-16 21:13:25 +00:00
Daniel James 49c0b2f333 Merged revisions 43206,43208-43213 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r43206 | danieljames | 2008-02-10 09:55:03 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Fix some broken links.
........
  r43209 | danieljames | 2008-02-10 14:56:22 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Link to people pages on the website, as they've been removed from the download.
........
  r43210 | danieljames | 2008-02-10 15:02:17 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Point links to the pages that used to be in 'more' to the site.
........
  r43212 | danieljames | 2008-02-10 16:10:16 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Fix links on the home page as well.
........
  r43213 | danieljames | 2008-02-10 16:21:22 +0000 (Sun, 10 Feb 2008) | 1 line
  
  Generated documentation which is no longer generated.
........


[SVN r43214]
2008-02-10 16:39:38 +00:00
Daniel James 0ad888867f Link to people pages on the website, as they've been removed from the download.
[SVN r43209]
2008-02-10 14:56:22 +00:00
Beman Dawes e9a5ac6d7a Merge conversion library at rev 41517
[SVN r42070]
2007-12-15 14:39:18 +00:00
Beman Dawes 408cbf0dcb Correct misspelling of library name
[SVN r42069]
2007-12-15 14:26:16 +00:00
Alexander Nasonov 808f210c0d Link to html version of [Tuning] and BOOST_LEXICAL_CAST_ASSUME_C_LOCALE synopsis
[SVN r41703]
2007-12-04 21:49:51 +00:00
Alexander Nasonov 69cf3b2766 Remove redundant BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION.
[SVN r41406]
2007-11-26 21:29:04 +00:00
Joaquín M López Muñoz ec8665d114 added missing traits template arg to a lexical_stream instantiation
[SVN r41394]
2007-11-26 11:52:03 +00:00
Alexander Nasonov 05036d3ae1 Support for string with non-default char_traits and allocator.
[SVN r41387]
2007-11-25 23:08:50 +00:00
Alexander Nasonov 159b045ad7 Pass unsigned type to lcast_put_unsigned.
[SVN r41385]
2007-11-25 22:28:16 +00:00
Beman Dawes ee3f643c5e Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41370]
2007-11-25 18:38:02 +00:00
Beman Dawes d44a6fcf8b Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
2007-11-25 18:07:19 +00:00
Alexander Nasonov 2cc7aedd28 minor changes
[SVN r41331]
2007-11-24 15:22:52 +00:00
Beman Dawes ac6e41d676 config, detail, filesystem, system, tools, at 41278.
[SVN r41316]
2007-11-23 17:03:14 +00:00
Eric Niebler 340f9b9e45 fix warning in gcc-4.3
[SVN r41258]
2007-11-20 16:52:43 +00:00
Beman Dawes 726f188aa4 // Add or correct comment identifying Boost library this header is associated with.
[SVN r41173]
2007-11-17 20:13:16 +00:00
Alexander Nasonov e70cf014ad #839 fixed: local variable shadow patch
[SVN r40816]
2007-11-05 22:22:48 +00:00
Joaquín M López Muñoz 0d6a924f94 applied workaround for MSVC++ 6.5/7.0 problem with static constants inside templates, see http://lists.boost.org/Archives/boost/2007/10/128392.php
[SVN r40146]
2007-10-18 06:57:25 +00:00
Beman Dawes 4224fa5deb Starting point for releases
[SVN r39706]
2007-10-05 14:25:06 +00:00
Vladimir Prus b9a7ee6deb Remove V1 Jamfiles
[SVN r38516]
2007-08-08 19:02:26 +00:00
nobody d6eea4ef81 This commit was manufactured by cvs2svn to create tag
'Version_1_34_1'.

[SVN r38286]
2007-07-24 19:28:14 +00:00
Alexander Nasonov 9c1f3650f2 Added BOOST_LEXICAL_CAST_ASSUME_C_LOCALE.
[SVN r37950]
2007-06-08 19:59:40 +00:00
Alexander Nasonov da5151abf6 added: FAQ and References section, updated: Changes
[SVN r37725]
2007-05-20 16:25:34 +00:00
Alexander Nasonov f986e8e588 Get rid of Tru64 cxx warnings
[SVN r37116]
2007-02-28 21:44:10 +00:00
Hartmut Kaiser 959b7ab0b4 Fixed a warning, when lexical cast is used to convert a boost::ulong_long_type to a string.
[SVN r37082]
2007-02-26 17:27:26 +00:00
Alexander Nasonov 42cb6d66cf lexical_cast_noncopyable_test.cpp
[SVN r36763]
2007-01-20 13:17:35 +00:00
Alexander Nasonov 209644c177 Better fix for SF:1358600
[SVN r36762]
2007-01-20 13:16:40 +00:00
Alexander Nasonov cf477316ed Documentation update for [ 1358600 ] lexical_cast & pure virtual functions & VC 8 STL
[SVN r36740]
2007-01-16 22:22:19 +00:00
Alexander Nasonov 986ec16ecc Fix [ 1358600 ] lexical_cast & pure virtual functions & VC 8 STL
[SVN r36739]
2007-01-16 21:53:27 +00:00
Alexander Nasonov 2c41ed0473 Fix for [ 1358600 ] lexical_cast & pure virtual functions & VC 8 STL
[SVN r36738]
2007-01-16 21:03:47 +00:00
Alexander Nasonov fcc28133c5 Presumably fix Boost.Test failures on Sun CC 5.3 (reported by Gennadiy Rozental)
[SVN r36464]
2006-12-20 08:01:48 +00:00
Vladimir Prus 37d07617d1 Fix
[SVN r35993]
2006-11-10 21:03:16 +00:00
Vladimir Prus bfeb60c400 Merge from HEAD.
Allow building of shared versions of some Boost.Test libraries.
Adjust tests to use always use static linking to Boost.Test, since
linking to the shared version requires test changes.

Patch from Juergen Hunold.


[SVN r35990]
2006-11-10 19:59:52 +00:00
Vladimir Prus de6746d67a Allow building of shared versions of some Boost.Test libraries.
Adjust tests to use always use static linking to Boost.Test, since
linking to the shared version requires test changes.

Patch from Juergen Hunold.


[SVN r35989]
2006-11-10 19:09:56 +00:00
Rene Rivera 78f1acc5ff Remove obsolete Boost.Build v1 files.
[SVN r35880]
2006-11-06 17:10:46 +00:00
Alexander Nasonov 67968d9b33 Separate test for round-tripping of floating point types.
[SVN r35771]
2006-10-28 19:33:32 +00:00
Alexander Nasonov c004fb5fc6 Fix the test built with <native-wchar_t>off on vc-7_1 and vc-8_0
[SVN r35760]
2006-10-28 14:37:37 +00:00
Alexander Nasonov ef439017ca Fixed: std::basic_streambuf<char, std::char_traits<char> > is an inaccessible base of boost::detail::lexical_streambuf<char>
[SVN r35759]
2006-10-28 10:22:30 +00:00
Alexander Nasonov fb63ebd4cd The test passed on VC6
[SVN r35755]
2006-10-27 21:28:33 +00:00
Alexander Nasonov 0f46451c1d One more VC6 workaround.
[SVN r35747]
2006-10-25 21:08:50 +00:00
Alexander Nasonov 663635d124 Optimization for floating types (1.25 faster on gcc / FreeBSD 6.2). VC6 test is still broken.
[SVN r35739]
2006-10-25 06:43:44 +00:00
Alexander Nasonov 4d69e9f2af VC6 workaround
[SVN r35738]
2006-10-25 06:41:21 +00:00
Alexander Nasonov d23f722228 Corrected a typo in comments.
[SVN r35611]
2006-10-14 17:58:33 +00:00
Alexander Nasonov e9767dc4e8 workarounds for test_round_conversion_long_double
[SVN r35606]
2006-10-14 10:09:49 +00:00
Alexander Nasonov 2b069eb3a3 test_round_conversion_long_double added to testsuite despite that it fails on FreeBSD and OpenBSD
[SVN r35600]
2006-10-13 22:27:53 +00:00
Alexander Nasonov 36db66bd12 Use metafunction (at compile-time), if possible; use run-time function only for broken libraries.
[SVN r35596]
2006-10-13 20:43:14 +00:00
Alexander Nasonov 4b1ca7bdf6 round conversion of floating point types: T -> std::string -> T
[SVN r35595]
2006-10-13 19:40:03 +00:00
Alexander Nasonov 0a605d1bb3 Use qualified name to fix graph tests
[SVN r35592]
2006-10-13 17:34:56 +00:00
Dave Abrahams 04de824ead vc6 workaround: help the compiler to distinguish overloads
[SVN r35566]
2006-10-12 06:39:14 +00:00
Alexander Nasonov 115ad05af5 Set precision correctly for builtin and UDT floating types.
[SVN r35562]
2006-10-11 19:43:54 +00:00
Alexander Nasonov ee7ea0011c Calculate/set stream precision for lexical_cast. May be useful for other libraries as well.
[SVN r35561]
2006-10-11 19:19:07 +00:00
Alexander Nasonov a2c7ddf5d9 no more gcc warnings
[SVN r35560]
2006-10-11 19:13:30 +00:00
Alexander Nasonov a7436ebacb setbuf renamed to lcast_setbuf to get rid of virtual function override warning
[SVN r34984]
2006-08-28 17:00:44 +00:00
Alexander Nasonov e797b09590 tabs replaced with 4 spaces
[SVN r34965]
2006-08-26 17:22:33 +00:00
Alexander Nasonov 2fca4d02a1 Optimization for many combinations of types
[SVN r34950]
2006-08-25 20:34:57 +00:00
Alexander Nasonov c17002aa73 get rid of lexical_cast.hpp impl details in the test
[SVN r34932]
2006-08-23 19:47:56 +00:00
Alexander Nasonov ae431bacf8 Better coverage
[SVN r34925]
2006-08-22 20:40:31 +00:00
Gennaro Prota 425e7cb367 removed BOOST_IMPLICIT_CAST; it was committed by mistake, has no unit tests, and is not released by the author under the Boost Software License
[SVN r34857]
2006-08-09 20:18:06 +00:00
Alexander Nasonov 453555619e New test cases for forthcoming fast lexical_cast
[SVN r34847]
2006-08-07 20:36:23 +00:00
Gennaro Prota 0743b5982c added slash to boost url
fixed silly error in #if/#endif logic of the previous edit
improved comment about code never reached
removed "All rights reserved"


[SVN r34822]
2006-08-06 12:31:44 +00:00
Gennaro Prota 795b7e1809 there seems to be no reasonable form which avoids warnings with all compilers; so let's use a clear style and filter explicitly the VC warning
[SVN r34820]
2006-08-05 22:45:53 +00:00
Gennaro Prota c5bc634015 some "rewording" to avoid spurious level 4 warnings with VC7.1 and VC8
[SVN r34801]
2006-08-01 22:37:38 +00:00
Gennaro Prota e6c83d0665 with apologies to Terje, changed 'ø' in 'o', to stick to the basic source
character set (non-basic chars should be handled in phase 1, but some users report compile failures due to them)


[SVN r34800]
2006-08-01 20:36:14 +00:00
Gennaro Prota aac8fcb4b6 boost guidelines (mainly from inspect tool: tabs, license reference text, etc.)
[SVN r34752]
2006-07-27 10:27:37 +00:00
Gennaro Prota abf3aa23de removed erroneous macro version
[SVN r34578]
2006-07-17 04:17:11 +00:00
Gennaro Prota 06e7d986d2 fixed library name, copyright notice, removed a tab char and a space-only line; NOTE: is the copyright notice autogenerated?
[SVN r34573]
2006-07-17 03:08:48 +00:00
Alexander Nasonov d436099477 Code size optimization
[SVN r33694]
2006-04-13 20:52:28 +00:00
nobody 74fc01da7e This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r33417]
2006-03-21 02:26:31 +00:00
Dave Abrahams 80e9edcb29 Stop using assert() in tests
[SVN r33181]
2006-02-28 22:56:33 +00:00
Beman Dawes 17ca3a4493 show arg as pased by const ref
[SVN r32840]
2006-02-12 01:17:17 +00:00
Vladimir Prus e5a0aec661 Revert (supposedly mistaken) removal of 'numeric_cast_test.cpp' from the
list of tests.


[SVN r32701]
2006-02-07 11:36:24 +00:00
Vladimir Prus 8cec2cc291 Update Jamfile.v2
[SVN r32700]
2006-02-07 11:35:31 +00:00
Stefan Slapeta 027a566e09 Small fix for new init_unit_test_suite signature
[SVN r32293]
2006-01-12 11:59:09 +00:00
Markus Schöpflin 9a29a753e8 Fixed lexical_cast_test which was no longer working after the last test
framework update.


[SVN r32176]
2005-12-28 11:05:31 +00:00
John Maddock cb2bd8076d Reconfigure lexical_cast to work wide character strings and VC++ when not using /Zc:wchar_t.
[SVN r30724]
2005-08-29 12:44:09 +00:00
John Maddock 1637edf8ca Large patch from Ulrich Eckhardt to fix support for EVC++ 4.
[SVN r30670]
2005-08-25 16:27:28 +00:00
Douglas Gregor 72d69ef6ad Merged from 1.33.0 release
[SVN r30540]
2005-08-12 13:02:37 +00:00
Fernando Cacciola 1470210523 fixed: "bcc5.6.4 added to the old cast redirection list"
[SVN r29814]
2005-06-27 15:05:13 +00:00
Douglas Gregor 0b19a0ae27 Fix line endings
[SVN r29773]
2005-06-24 14:24:02 +00:00
Dave Abrahams 3ab685475c Move #include outside namespace.
[SVN r29772]
2005-06-24 14:20:41 +00:00
Fernando Cacciola e66d58e6de Old numeric_cast<> completely replaced by new code (except that the old code is retained as a fallback mechanism for old broken compilers that can't deal with the new code)
[SVN r29761]
2005-06-23 23:33:01 +00:00
Joaquín M. López Muñoz e331fc2a21 workaround for GCC 2.9x lacking std::char_traits<>::eof()
[SVN r29703]
2005-06-20 10:54:07 +00:00
Joaquín M. López Muñoz 2a65633517 fixed trivial bug
[SVN r29654]
2005-06-17 12:34:38 +00:00
Terje Slettebø 7a388cb1a6 Fixed so it doesn't trim any whitespace when converting, fixed reversed bad_lexical_cast constructor parameters, changed to pass-by-const reference
[SVN r29630]
2005-06-16 18:37:51 +00:00
Terje Slettebø 461dce3851 Fixed so it doesn't trim any whitespace when converting, fixed reversed bad_lexical_cast constructor parameters, changed to pass-by-const reference
[SVN r29629]
2005-06-16 18:27:22 +00:00
Terje Slettebø cfe358b570 Fixed so it doesn't trim any whitespace when converting, fixed reversed bad_lexical_cast constructor parameters, changed to pass-by-const reference
[SVN r29627]
2005-06-16 18:16:58 +00:00
Vladimir Prus caa875505e Update
[SVN r28239]
2005-04-14 11:20:26 +00:00
Dave Abrahams 462025d8e6 Fix docs
[SVN r27509]
2005-02-26 14:58:12 +00:00
Aleksey Gurtovoy b8c373ab47 c++boost.gif -> boost.png replacement
[SVN r25573]
2004-10-05 15:45:52 +00:00
Aleksey Gurtovoy f6b0ec3685 fix syntax errors
[SVN r25473]
2004-09-29 11:44:04 +00:00
Fernando Cacciola a096a4b153 numeric_cast<> test factored out from conversion\cast_test.cp
and also added (duplicated) in numeric\conversion\test


[SVN r25468]
2004-09-28 21:48:39 +00:00
John Maddock bba9169401 Updated to use the BSL: Permission from Kevlin Henney was granted in blanket-permission.txt, permission from Terje Slettebo was granted for this one file privately.
[SVN r25402]
2004-09-25 15:06:48 +00:00
John Maddock f11967a2c8 BSL update
[SVN r25146]
2004-09-16 11:23:30 +00:00
John Maddock c1c338990c Added new types boost::long_long_type and boost::ulong_long_type in boost/config.hpp and applied these types in place of "long long" throughout. As a result, almost all of boost now compiles cleanly with -ansi -pedantic with gcc. Changes tested with gcc 3.3, 2.95, VC7.1 and Intel 8.
[SVN r24899]
2004-09-04 10:34:49 +00:00
John Maddock ec35f00bc3 Removed boost.org copyright assignments, and reverted to orginal author (as based on cvs history).
[SVN r24402]
2004-08-11 10:59:33 +00:00
Douglas Gregor abf8ee0eb9 Converted to Boost Software License, Version 1.0
[SVN r24055]
2004-07-26 00:32:12 +00:00
Eric Niebler 463284f46f remove minmax hack from win32.hpp and fix all places that could be affected by the minmax macros
[SVN r22394]
2004-02-26 18:27:02 +00:00
Beman Dawes 9f5ec17603 index.htm renamed index.html
[SVN r21230]
2003-12-11 23:13:19 +00:00
Vladimir Prus 575c477f54 Add V2 Jamfile
[SVN r20209]
2003-09-29 15:38:40 +00:00
Dave Abrahams e6c52ae0f4 Improved justification for polymorphic_cast.
[SVN r20068]
2003-09-15 16:30:22 +00:00
Dave Abrahams 13796f3f98 Use the import rule
[SVN r19968]
2003-09-08 17:38:49 +00:00
Dave Abrahams 80a6db56c1 Warning suppression for GCC from Pierre Barbier de Reuille
<pierre.barbier-at-cirad.fr>


[SVN r19437]
2003-08-04 15:52:51 +00:00
Jens Maurer 25935cda40 avoid warning about signed/unsigned conversion
[SVN r19007]
2003-07-09 22:30:40 +00:00
Dave Abrahams 386d7a67d6 initial commit
[SVN r18350]
2003-05-07 22:42:35 +00:00
Beman Dawes 4b3e8171fa Initial re-commit after CVS disk crash
[SVN r18348]
2003-05-07 20:41:11 +00:00
Terje Slettebø 498c84dd4f no message
[SVN r18238]
2003-04-12 08:02:14 +00:00
John Maddock 3ecac311fd Added no exception handling patch
[SVN r18235]
2003-04-11 10:49:52 +00:00
Terje Slettebø 8828af5f5b no message
[SVN r18142]
2003-03-31 23:02:27 +00:00
Terje Slettebø 1937e3a12a Added test case for unsigned types, in case they are an alias for wchar_t
[SVN r18141]
2003-03-31 08:29:45 +00:00
Terje Slettebø 545687e22b Removed test for MSVC, restored test for BOOST_NO_INTRINSIC_WCHAR_T
[SVN r18140]
2003-03-30 23:21:17 +00:00
Terje Slettebø 9c63f9fbd0 Removed test for MSVC, restored test for BOOST_NO_INTRINSIC_WCHAR_T. Changed bad_lexical_cast to provide the types used, using source()/target() members
[SVN r18139]
2003-03-30 23:19:28 +00:00
Terje Slettebø 9c1311a712 BOOST_MSVC<=1200 fix from Terje
[SVN r18019]
2003-03-19 21:25:45 +00:00
Beman Dawes 51395d7b26 BOOST_MSVC<=1200 fix from Terje
[SVN r18002]
2003-03-19 12:14:32 +00:00
Dave Abrahams 02609a4675 Commit Terje's changes
[SVN r17980]
2003-03-18 22:46:00 +00:00
Dave Abrahams 52de514faf Commit Terje's changes
[SVN r17979]
2003-03-18 22:34:32 +00:00
Terje Slettebø ae7d610cb1 Updated Changes section
[SVN r17922]
2003-03-14 20:32:51 +00:00
Terje Slettebø eb9d2c02ea no message
[SVN r17921]
2003-03-14 20:17:47 +00:00
Beman Dawes e2825ab729 overloading fix + less permissive wide character support
[SVN r17893]
2003-03-13 17:27:06 +00:00
Beman Dawes 4978f3a79f BOOST_NO_STD_WSTRING
[SVN r17872]
2003-03-13 00:36:13 +00:00
Beman Dawes 42639f120a update from Kevlin and Terje
[SVN r17861]
2003-03-12 21:33:16 +00:00
28 changed files with 1517 additions and 1748 deletions
+11
View File
@@ -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"
+182
View File
@@ -0,0 +1,182 @@
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
UBSAN_OPTIONS: print_stacktrace=1
jobs:
posix:
strategy:
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
- toolset: gcc-12
cxxstd: "03,11,14,17,2a"
os: ubuntu-22.04
cxxflags: "cxxflags=--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined"
linkflags: "linkflags=--coverage -lasan -lubsan"
gcov_tool: "gcov-12"
- toolset: clang
compiler: clang++-14
cxxstd: "03,11,14,17,2a"
os: ubuntu-22.04
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 10 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init --depth 10 --jobs 2 tools/boostdep tools/inspect libs/filesystem
python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 3" filesystem
rm -rf libs/$LIBRARY/*
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 -j4 variant=debug tools/inspect
- name: Run CMake tests
if: ${{matrix.toolset == 'gcc-14'}}
run: |
cd ../boost-root/
mkdir __build
cd __build
cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=conversion -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER=gcc-14 ..
cmake --build . --target tests
ctest --output-on-failure --no-tests=error
cd ..
rm -rf __build
- name: Run tests
run: |
cd ../boost-root
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release "${{matrix.cxxflags}}" "${{matrix.linkflags}}" "${{matrix.launcher}}"
dist/bin/inspect libs/$LIBRARY
- name: Prepare coverage data
if: matrix.gcov_tool
run: |
mkdir -p $GITHUB_WORKSPACE/coveralls
echo -e "#!/bin/bash\nexec ${{matrix.gcov_tool}} \"\$@\"" > $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh
chmod +x $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh
wget https://github.com/linux-test-project/lcov/archive/v1.16.zip
unzip v1.16.zip
LCOV="`pwd`/lcov-1.16/bin/lcov --gcov-tool $GITHUB_WORKSPACE/coveralls/gcov_wrapper.sh"
echo "$LCOV --directory ../boost-root/bin.v2/libs/$LIBRARY/ --base-directory `pwd`/libs/$LIBRARY/test --capture --output-file $GITHUB_WORKSPACE/coveralls/coverage.info"
$LCOV --directory ../boost-root/bin.v2/libs/$LIBRARY/ --base-directory ../boost-root/ --capture --output-file $GITHUB_WORKSPACE/coveralls/coverage.info
$LCOV --remove $GITHUB_WORKSPACE/coveralls/coverage.info "/usr*" "*/$LIBRARY/test/*" ${{matrix.ignore_coverage}} "*/$LIBRARY/tests/*" "*/$LIBRARY/examples/*" "*/$LIBRARY/example/*" -o $GITHUB_WORKSPACE/coveralls/coverage.info
cd ../boost-root
OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$LIBRARY\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'`
echo $OTHER_LIBS
eval "$LCOV --remove $GITHUB_WORKSPACE/coveralls/coverage.info $OTHER_LIBS -o $GITHUB_WORKSPACE/coveralls/coverage.info"
- name: Coveralls
uses: coverallsapp/github-action@master
if: matrix.gcov_tool
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coveralls/coverage.info
parallel: true
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.3
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2025
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2025
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v6
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
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
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
- 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=conversion ..
cmake --build . --target tests --config Debug
ctest --output-on-failure --no-tests=error -C Debug
cd ..
rm -rf __build
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
finish:
needs: posix
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
+22
View File
@@ -0,0 +1,22 @@
# Copyright 2019 Mike Dev
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required( VERSION 3.5...4.20 )
project( boost_conversion VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX )
add_library( boost_conversion INTERFACE )
add_library( Boost::conversion ALIAS boost_conversion )
target_include_directories( boost_conversion INTERFACE include )
target_link_libraries( boost_conversion
INTERFACE
Boost::assert
Boost::config
Boost::throw_exception
)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
+15
View File
@@ -0,0 +1,15 @@
# [Boost.Conversion](https://boost.org/libs/conversion)
Boost.Conversion is one of the [Boost C++ Libraries](https://github.com/boostorg). This library improves program safety and clarity by performing otherwise messy conversions.
### Test results
@ | Build | Tests coverage | More info
----------------|-------------- | -------------- |-----------
Develop branch: | [![CI](https://github.com/boostorg/conversion/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/conversion/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/1cky1hrunfa46bdx/branch/develop?svg=true)](https://ci.appveyor.com/project/apolukhin/conversion/branch/develop) | [![Coverage Status](https://coveralls.io/repos/github/boostorg/conversion/badge.svg?branch=develop)](https://coveralls.io/github/boostorg/conversion?branch=develop) | [details...](https://regression.boost.io/develop/developer/conversion.html)
Master branch: | [![CI](https://github.com/boostorg/conversion/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/conversion/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/1cky1hrunfa46bdx/branch/master?svg=true)](https://ci.appveyor.com/project/apolukhin/conversion/branch/master) | [![Coverage Status](https://coveralls.io/repos/github/boostorg/conversion/badge.svg?branch=master)](https://coveralls.io/github/boostorg/conversion?branch=master) | [details...](https://regression.boost.io/master/developer/conversion.html)
[Latest developer documentation](https://www.boost.org/doc/libs/develop/doc/html/conversion.html)
### License
Distributed under the [Boost Software License, Version 1.0](https://boost.org/LICENSE_1_0.txt).
+25
View File
@@ -0,0 +1,25 @@
# 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/assert//boost_assert
/boost/config//boost_config
/boost/throw_exception//boost_throw_exception ;
project /boost/conversion
: common-requirements
<include>include
;
explicit
[ alias boost_conversion : : : : <library>$(boost_dependencies) ]
[ alias all : boost_conversion test ]
;
call-if : boost-library conversion
;
-150
View File
@@ -1,150 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Header boost/cast.hpp Documentation</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" align="middle" width="277" height="86">Header
<a href="../../boost/cast.hpp">boost/cast.hpp</a></h1>
<h2><a name="Cast Functions">Cast Functions</a></h2>
<p>The header <a href="../../boost/cast.hpp">boost/cast.hpp</a>
provides <a href="#Polymorphic_cast"><b>polymorphic_cast</b></a>, <a href="#Polymorphic_cast"><b>polymorphic_downcast</b></a>,
and <a href="#numeric_cast"><b>numeric_cast</b></a> function templates designed
to complement the C++ built-in casts.</p>
<p>The program <a href="cast_test.cpp">cast_test.cpp</a> can be used to
verify these function templates work as expected.</p>
<h3><a name="Polymorphic_cast">Polymorphic casts</a></h3>
<p>Pointers to polymorphic objects (objects of classes which define at least one
virtual function) are sometimes downcast or crosscast. Downcasting means
casting from a base class to a derived class. Crosscasting means casting
across an inheritance hierarchy diagram, such as from one base to the other in a
<b>Y</b> diagram hierarchy.</p>
<p>Such casts can be done with old-style casts, but this approach is never to be
recommended. Old-style casts are sorely lacking in type safety, suffer
poor readability, and are difficult to locate with search tools.</p>
<p>The C++ built-in <b>static_cast</b> can be used for efficiently downcasting
pointers to polymorphic objects, but provides no error detection for the case
where the pointer being cast actually points to the wrong derived class. The <b>polymorphic_downcast</b>
template retains the efficiency of <b>static_cast</b> for non-debug
compilations, but for debug compilations adds safety via an assert() that a <b>dynamic_cast</b>
succeeds.</p>
<p>The C++ built-in <b>dynamic_cast</b> can be used for downcasts and crosscasts
of pointers to polymorphic objects, but error notification in the form of a
returned value of 0 is inconvenient to test, or worse yet, easy to forget to
test. The <b>polymorphic_cast</b> template performs a <b>dynamic_cast</b>,
and throws an exception if the <b>dynamic_cast</b> returns 0.</p>
<p>A <b>polymorphic_downcast</b> is preferred when debug-mode tests will cover
100% of the object types possibly cast and when non-debug-mode efficiency is an
issue. If these two conditions are not present, <b>polymorphic_cast</b> is
preferred. It must also be used for crosscasts. It does an assert(
dynamic_cast&lt;Derived&gt;(x) == x ) where x is the base pointer, ensuring that
not only is a non-zero pointer returned, but also that it correct in the
presence of multiple inheritance.<b> Warning:</b>: Because <b>polymorphic_downcast</b>
uses assert(), it violates the one definition rule (ODR) if NDEBUG is inconsistently
defined across translation units. [See ISO Std 3.2]</p>
<p>The C++ built-in <b>dynamic_cast</b> must be used to cast references rather
than pointers. It is also the only cast that can be used to check whether
a given interface is supported; in that case a return of 0 isn't an error
condition.</p>
<h3>polymorphic_cast and polymorphic_downcast synopsis</h3>
<blockquote>
<pre>namespace boost {
template &lt;class Derived, class Base&gt;
inline Derived polymorphic_cast(Base* x);
// Throws: std::bad_cast if ( dynamic_cast&lt;Derived&gt;(x) == 0 )
// Returns: dynamic_cast&lt;Derived&gt;(x)
template &lt;class Derived, class Base&gt;
inline Derived polymorphic_downcast(Base* x);
// Effects: assert( dynamic_cast&lt;Derived&gt;(x) == x );
// Returns: static_cast&lt;Derived&gt;(x)
}</pre>
</blockquote>
<h3>polymorphic_downcast example</h3>
<blockquote>
<pre>#include &lt;boost/cast.hpp&gt;
...
class Fruit { public: virtual ~Fruit(){}; ... };
class Banana : public Fruit { ... };
...
void f( Fruit * fruit ) {
// ... logic which leads us to believe it is a Banana
Banana * banana = boost::polymorphic_downcast&lt;Banana*&gt;(fruit);
...</pre>
</blockquote>
<h3><a name="numeric_cast">numeric_cast</a></h3>
<p>A <b>static_cast</b> or implicit conversion will not
detect failure to preserve range for numeric casts. The <b>numeric_cast</b> function
templates are similar to <b>static_cast</b> and certain (dubious)
implicit conversions in this respect, except that they detect loss of numeric
range. An exception is thrown when a runtime value-preservation check fails.</p>
<p>The requirements on the argument and result types are:</p>
<blockquote>
<ul>
<li>Both argument and result types are CopyConstructible [ISO Std 20.1.3].</li>
<li>Both argument and result types are Numeric, defined by <code>std::numeric_limits&lt;&gt;::is_specialized</code>
being true.</li>
<li>The argument can be converted to the result type using <b>static_cast</b>.</li>
</ul>
</blockquote>
<h3>numeric_cast synopsis</h3>
<blockquote>
<pre>namespace boost {
class bad_numeric_cast : public std::bad_cast {...};
template&lt;typename Target, typename Source&gt;
inline Target numeric_cast(Source arg);
// Throws: bad_numeric_cast unless, in converting arg from Source to Target,
// there is no loss of negative range, and no underflow, and no
// overflow, as determined by std::numeric_limits
// Returns: static_cast&lt;Target&gt;(arg)
}</pre>
</blockquote>
<h3>numeric_cast example</h3>
<blockquote>
<pre>#include &lt;boost/cast.hpp&gt;
using namespace boost::cast;
void ariane(double vx)
{
...
unsigned short dx = numeric_cast&lt;unsigned short&gt;(vx);
...
}</pre>
</blockquote>
<h3>numeric_cast rationale</h3>
<p>The form of the throws condition is specified so that != is not a required
operation.</p>
<h3>History</h3>
<p><b>polymorphic_cast</b> was suggested by Bjarne Stroustrup in &quot;The C++
Programming Language&quot;.<br>
<b>polymorphic_downcast</b> was contributed by <a href="../../people/dave_abrahams.htm">Dave
Abrahams</a>.<b><br>
numeric_cast</b> was contributed by <a href="../../people/kevlin_henney.htm">Kevlin
Henney</a>.</p>
<hr>
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan
-->06 January, 2001<!--webbot bot="Timestamp" endspan i-checksum="38320"
--></p>
<p>© Copyright boost.org 1999. Permission to copy, use, modify, sell and
distribute this document is granted provided this copyright notice appears in
all copies. This document is provided &quot;as is&quot; without express or
implied warranty, and with no claim as to its suitability for any purpose.</p>
</body>
</html>
-154
View File
@@ -1,154 +0,0 @@
// boost utility cast test program -----------------------------------------//
// (C) Copyright boost.org 1999. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 20 Jan 01 removed use of <limits> for portability to raw GCC (David Abrahams)
// 28 Jun 00 implicit_cast removed (Beman Dawes)
// 30 Aug 99 value_cast replaced by numeric_cast
// 3 Aug 99 Initial Version
#include <iostream>
#include <climits>
#include <cfloat> // for DBL_MAX (Peter Schmid)
#include <boost/cast.hpp>
# if SCHAR_MAX == LONG_MAX
# error "This test program doesn't work if SCHAR_MAX == LONG_MAX"
# endif
using namespace boost;
using std::cout;
namespace
{
struct Base
{
virtual char kind() { return 'B'; }
};
struct Base2
{
virtual char kind2() { return '2'; }
};
struct Derived : public Base, Base2
{
virtual char kind() { return 'D'; }
};
}
int main( int argc, char * argv[] )
{
cout << "Usage: test_casts [n], where n omitted or is:\n"
" 1 = execute #1 assert failure (#ifndef NDEBUG)\n"
" 2 = execute #2 assert failure (#ifndef NDEBUG)\n"
"Example: test_casts 2\n\n";
# ifdef NDEBUG
cout << "NDEBUG is defined\n";
# else
cout << "NDEBUG is not defined\n";
# endif
cout << "\nBeginning tests...\n";
// test polymorphic_cast ---------------------------------------------------//
// tests which should succeed
Base * base = new Derived;
Base2 * base2 = 0;
Derived * derived = 0;
derived = polymorphic_downcast<Derived*>( base ); // downcast
assert( derived->kind() == 'D' );
derived = 0;
derived = polymorphic_cast<Derived*>( base ); // downcast, throw on error
assert( derived->kind() == 'D' );
base2 = polymorphic_cast<Base2*>( base ); // crosscast
assert( base2->kind2() == '2' );
// tests which should result in errors being detected
int err_count = 0;
base = new Base;
if ( argc > 1 && *argv[1] == '1' )
{ derived = polymorphic_downcast<Derived*>( base ); } // #1 assert failure
bool caught_exception = false;
try { derived = polymorphic_cast<Derived*>( base ); }
catch (std::bad_cast)
{ cout<<"caught bad_cast\n"; caught_exception = true; }
if ( !caught_exception ) ++err_count;
// the following is just so generated code can be inspected
if ( derived->kind() == 'B' ) ++err_count;
// test implicit_cast and numeric_cast -------------------------------------//
// tests which should succeed
long small_value = 1;
long small_negative_value = -1;
long large_value = LONG_MAX;
long large_negative_value = LONG_MIN;
signed char c = 0;
c = large_value; // see if compiler generates warning
c = numeric_cast<signed char>( small_value );
assert( c == 1 );
c = 0;
c = numeric_cast<signed char>( small_value );
assert( c == 1 );
c = 0;
c = numeric_cast<signed char>( small_negative_value );
assert( c == -1 );
// These tests courtesy of Joe R NWP Swatosh<joe.r.swatosh@usace.army.mil>
assert( 0.0f == numeric_cast<float>( 0.0 ) );
assert( 0.0 == numeric_cast<double>( 0.0 ) );
// tests which should result in errors being detected
caught_exception = false;
try { c = numeric_cast<signed char>( large_value ); }
catch (bad_numeric_cast)
{ cout<<"caught bad_numeric_cast #1\n"; caught_exception = true; }
if ( !caught_exception ) ++err_count;
caught_exception = false;
try { c = numeric_cast<signed char>( large_negative_value ); }
catch (bad_numeric_cast)
{ cout<<"caught bad_numeric_cast #2\n"; caught_exception = true; }
if ( !caught_exception ) ++err_count;
unsigned long ul;
caught_exception = false;
try { ul = numeric_cast<unsigned long>( large_negative_value ); }
catch (bad_numeric_cast)
{ cout<<"caught bad_numeric_cast #3\n"; caught_exception = true; }
if ( !caught_exception ) ++err_count;
caught_exception = false;
try { ul = numeric_cast<unsigned long>( small_negative_value ); }
catch (bad_numeric_cast)
{ cout<<"caught bad_numeric_cast #4\n"; caught_exception = true; }
if ( !caught_exception ) ++err_count;
caught_exception = false;
try { numeric_cast<int>( DBL_MAX ); }
catch (bad_numeric_cast)
{ cout<<"caught bad_numeric_cast #5\n"; caught_exception = true; }
if ( !caught_exception ) ++err_count;
cout << err_count << " errors detected\nTest "
<< (err_count==0 ? "passed\n" : "failed\n");
return err_count;
} // main
+38
View File
@@ -0,0 +1,38 @@
# Copyright (c) 2016 Mikhail Maximov <vigorous.activity -at- gmail.com>
# 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)
project doc/conversion ;
using quickbook ;
import boostbook ;
xml conversion : conversion.qbk ;
boostbook standalone
:
conversion
:
<xsl:param>boost.root=../../../..
# File name of HTML output:
<xsl:param>root.filename=conversion
# How far down we chunk nested sections, basically all of them:
<xsl:param>chunk.section.depth=0
# Don't put the first section on the same page as the TOC:
<xsl:param>chunk.first.sections=0
# How far down sections get TOC's
<xsl:param>toc.section.depth=2
# Max depth in each TOC:
<xsl:param>toc.max.depth=2
# How far down we go with TOC's
<xsl:param>generate.section.toc.level=0
<xsl:param>generate.manifest=0
;
###############################################################################
alias boostdoc : conversion ;
explicit boostdoc ;
alias boostrelease ;
explicit boostrelease ;
+215
View File
@@ -0,0 +1,215 @@
[/
Copyright 2016 Mikhail Maximov.
Copyright Antony Polukhin, 2020-2026.
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)
]
[article The Conversion Library
[quickbook 1.6]
[compatibility-mode 1.5]
[id conversion]
[version 1.7]
[authors [Stroustrup, Bjarne], [Abrahams, Dave], [Rasin, Boris], [Polukhin, Antony]]
[copyright 2001 Beman Dawes, 2014-2026 Antony Polukhin]
[license
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])
]
[source-mode c++]
]
[/ QuickBook Document version 1.5 ]
[/ Dec, 2016 ]
[section Description]
The Conversion Library improves program safety and clarity by performing
otherwise messy conversions. It includes cast-style function templates designed
to complement the C++ Standard's built-in casts.
To reduce coupling, the Boost Conversion Library is supplied by several headers:
# The [@boost:boost/polymorphic_cast.hpp boost/polymorphic_cast.hpp] header
provides [link polymorphic_cast `polymorphic_cast<>`] and
[link polymorphic_downcast `polymorphic_downcast<>`]
to perform safe casting between polymorphic types.
# The [@boost:boost/polymorphic_pointer_cast.hpp boost/polymorphic_pointer_cast.hpp] header
provides [link polymorphic_pointer_cast `polymorphic_pointer_cast<>`] and
[link polymorphic_pointer_cast `polymorphic_pointer_downcast<>`]
# The [@boost:boost/implicit_cast.hpp boost/implicit_cast.hpp] header provides `implicit_cast<>`
to perform implicit casts only (no down-cast, no void*->T*, no U->T if T has only explicit constructors for U).
[endsect]
[section Polymorphic casts]
Pointers to polymorphic objects (objects of classes which define at
least one virtual function) are sometimes downcast or crosscast.
Downcasting means casting from a base class to a derived class.
Crosscasting means casting across an inheritance hierarchy diagram, such
as from one base to the other in a [^Y] diagram hierarchy.
Such casts can be done with old-style casts, but this approach is
never to be recommended. Old-style casts are sorely lacking in type
safety, suffer poor readability, and are difficult to locate with search
tools.
[#polymorphic_downcast]
[section polymorphic_downcast]
The C++ built-in `static_cast` can be used for efficiently
downcasting pointers to polymorphic objects, but provides no error
detection for the case where the pointer being cast actually points to
the wrong derived class. The `polymorphic_downcast` template retains
the efficiency of `static_cast` for non-debug compilations, but for
debug compilations adds safety via an `assert()` that a `dynamic_cast`
succeeds.
A `polymorphic_downcast` should be used for
downcasts that you are certain should succeed. Error checking is
only performed in translation units where `NDEBUG` is
not defined, via
```
assert( dynamic_cast<Derived>(x) == x )
```
where `x` is the source pointer. This approach
ensures that not only is a non-zero pointer returned, but also
that it is correct in the presence of multiple inheritance.
Attempts to crosscast using `polymorphic_downcast` will
fail to compile.
[warning Because `polymorphic_downcast` uses `assert()`, it
violates the One Definition Rule (ODR) if `NDEBUG` is inconsistently
defined across translation units. See ISO Std 3.2]
[h4 Example:]
```
#include <boost/polymorphic_cast.hpp>
...
class Fruit { public: virtual ~Fruit(){}; ... };
class Banana : public Fruit { ... };
...
void f( Fruit * fruit ) {
// ... logic which leads us to believe it is a Banana
Banana * banana = boost::polymorphic_downcast<Banana*>(fruit);
...
}
```
[endsect]
[#polymorphic_cast]
[section polymorphic_cast]
The C++ built-in `dynamic_cast` can be used for downcasts and
crosscasts of pointers to polymorphic objects, but error notification in
the form of a returned value of 0 is inconvenient to test, or worse yet,
easy to forget to test. The throwing form of `dynamic_cast`, which
works on references, can be used on pointers through the ugly expression
`&dynamic_cast<T&>(*p)`, which causes undefined
behavior if `p` is `0`. The `polymorphic_cast`
template performs a `dynamic_cast` on a pointer, and throws an
exception if the `dynamic_cast` returns 0.
For crosscasts, or when the success of a cast can only be known at runtime,
or when efficiency is not important, `polymorphic_cast` is preferred.
The C++ built-in `dynamic_cast` must be used to cast references rather than pointers.
It is also the only cast that can be used to check whether a given interface is supported; in that case a return of 0 isn't an error condition.
[endsect]
[#polymorphic_pointer_cast]
[section polymorphic_pointer_cast]
While `polymorphic_downcast` and `polymorphic_cast` work with built-in pointer types only,
`polymorphic_pointer_downcast` and `polymorphic_pointer_cast` are more generic versions
with support for any pointer type for which the following expressions would be valid:
For `polymorphic_pointer_downcast`:
```
static_pointer_cast<Derived>(p);
dynamic_pointer_cast<Derived>(p);
```
For `polymorphic_pointer_cast`:
```
dynamic_pointer_cast<Derived>(p);
!p; // conversion to bool with negation
```
This includes C++ built-in pointers, `std::shared_ptr`,
`boost::shared_ptr`, `boost::intrusive_ptr`, etc.
[h4 Example:]
```
#include <boost/polymorphic_pointer_cast.hpp>
class Fruit { public: virtual ~Fruit(){} };
class Banana : public Fruit {};
// Use one of these:
using FruitPtr = Fruit*;
using FruitPtr = std::shared_ptr<Fruit>;
using FruitPtr = boost::shared_ptr<Fruit>;
using FruitPtr = boost::intrusive_ptr<Fruit>;
void f(FruitPtr fruit) {
// ... logic which leads us to believe it is a banana
auto banana = boost::polymorphic_pointer_downcast<Banana>(fruit);
...
}
```
[endsect]
[endsect]
[section Synopsis]
```
namespace boost {
// Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 )
// Returns: dynamic_cast<Derived>(x)
template <class Derived, class Base>
constexpr Derived polymorphic_cast(Base* x);
// Effects: assert( dynamic_cast<Derived>(x) == x );
// Returns: static_cast<Derived>(x)
template <class Derived, class Base>
constexpr Derived polymorphic_downcast(Base* x);
// Effects: assert( dynamic_cast<Derived>(&x) == &x );
// Returns: static_cast<Derived>(x)
template <class Derived, class Base>
constexpr Derived polymorphic_downcast(Base& x);
// Throws: std::bad_cast if ( dynamic_pointer_cast<Derived>(x) == 0 )
// Returns: dynamic_pointer_cast<Derived>(x)
template <class Derived, class Base>
inline auto polymorphic_pointer_cast(Base x);
// Effects: assert( dynamic_pointer_cast<Derived>(x) == x );
// Returns: static_pointer_cast<Derived>(x)
template <class Derived, class Base>
inline auto polymorphic_pointer_downcast(Base x);
}
```
[endsect]
[section History]
`polymorphic_cast` was suggested by Bjarne Stroustrup in "The C++ Programming Language".
`polymorphic_downcast` was contributed by [@http://www.boost.org/people/dave_abrahams.htm Dave Abrahams].
`polymorphic_pointer_downcast` was contributed by [@http://www.boost.org/people/boris_rasin.htm Boris Rasin]
and `polymorphic_pointer_cast` by Antony Polukhin.
`polymorphic_downcast` overload for references was contributed by Julien Delacroix.
An old `numeric_cast` that was contributed by [@http://www.boost.org/people/kevlin_henney.htm Kevlin Henney]
is now superseded by the [@boost:numeric_conversion/doc/html/html/boost_numericconversion/improved_numeric_cast__.html Boost Numeric Conversion Library]
[endsect]
-385
View File
@@ -1,385 +0,0 @@
// boost cast.hpp header file ----------------------------------------------//
// (C) Copyright boost.org 1999. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// See http://www.boost.org/libs/conversion for Documentation.
// Revision History
// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included
// <boost/limits.hpp> instead (the workaround did not
// actually compile when BOOST_NO_LIMITS was defined in
// any case, so we loose nothing). (John Maddock)
// 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never
// worked with stock GCC; trying to get it to do that broke
// vc-stlport.
// 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp.
// Removed unused BOOST_EXPLICIT_TARGET macro. Moved
// boost::detail::type to boost/type.hpp. Made it compile with
// stock gcc again (Dave Abrahams)
// 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal
// Review (Beman Dawes)
// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams)
// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC
// (Dave Abrahams)
// 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams)
// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes)
// 27 Jun 00 More MSVC6 workarounds
// 15 Jun 00 Add workarounds for MSVC6
// 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov)
// 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar)
// 29 Dec 99 Change using declarations so usages in other namespaces work
// correctly (Dave Abrahams)
// 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors
// as suggested Darin Adler and improved by Valentin Bonnard.
// 2 Sep 99 Remove controversial asserts, simplify, rename.
// 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast,
// place in nested namespace.
// 3 Aug 99 Initial version
#ifndef BOOST_CAST_HPP
#define BOOST_CAST_HPP
# include <boost/config.hpp>
# include <cassert>
# include <typeinfo>
# include <boost/type.hpp>
# include <boost/limits.hpp>
# include <boost/detail/select_type.hpp>
// It has been demonstrated numerous times that MSVC 6.0 fails silently at link
// time if you use a template function which has template parameters that don't
// appear in the function's argument list.
//
// TODO: Add this to config.hpp?
# if defined(BOOST_MSVC) && BOOST_MSVC <= 1200 // 1200 = VC6
# define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type<Target>* = 0
# else
# define BOOST_EXPLICIT_DEFAULT_TARGET
# endif
namespace boost
{
// See the documentation for descriptions of how to choose between
// static_cast<>, dynamic_cast<>, polymorphic_cast<> and polymorphic_downcast<>
// polymorphic_cast --------------------------------------------------------//
// Runtime checked polymorphic downcasts and crosscasts.
// Suggested in The C++ Programming Language, 3rd Ed, Bjarne Stroustrup,
// section 15.8 exercise 1, page 425.
template <class Target, class Source>
inline Target polymorphic_cast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET)
{
Target tmp = dynamic_cast<Target>(x);
if ( tmp == 0 ) throw std::bad_cast();
return tmp;
}
// polymorphic_downcast ----------------------------------------------------//
// assert() checked polymorphic downcast. Crosscasts prohibited.
// WARNING: Because this cast uses assert(), it violates the One Definition
// Rule if NDEBUG is inconsistently defined across translation units.
// Contributed by Dave Abrahams
template <class Target, class Source>
inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET)
{
assert( dynamic_cast<Target>(x) == x ); // detect logic error
return static_cast<Target>(x);
}
// implicit_cast -----------------------------------------------------------//
//
// Removed due to uncertain purpose. Use either numeric_cast (see below)
// or static_cast according to the need.
// numeric_cast and related exception --------------------------------------//
// Contributed by Kevlin Henney
// bad_numeric_cast --------------------------------------------------------//
// exception used to indicate runtime numeric_cast failure
class bad_numeric_cast : public std::bad_cast
{
public:
// constructors, destructors and assignment operator defaulted
// function inlined for brevity and consistency with rest of library
virtual const char *what() const throw()
{
return "bad numeric cast: loss of range in numeric_cast";
}
};
// numeric_cast ------------------------------------------------------------//
#if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || defined(BOOST_SGI_CPP_LIMITS)
namespace detail
{
template <class T>
struct signed_numeric_limits : std::numeric_limits<T>
{
static inline T min()
{
return std::numeric_limits<T>::min() >= 0
// unary minus causes integral promotion, thus the static_cast<>
? static_cast<T>(-std::numeric_limits<T>::max())
: std::numeric_limits<T>::min();
};
};
// Move to namespace boost in utility.hpp?
template <class T, bool specialized>
struct fixed_numeric_limits_base
: public if_true< std::numeric_limits<T>::is_signed >
::BOOST_NESTED_TEMPLATE then< signed_numeric_limits<T>,
std::numeric_limits<T>
>::type
{};
template <class T>
struct fixed_numeric_limits
: fixed_numeric_limits_base<T,(std::numeric_limits<T>::is_specialized)>
{};
# ifdef BOOST_HAS_LONG_LONG
// cover implementations which supply no specialization for long
// long / unsigned long long. Not intended to be full
// numeric_limits replacements, but good enough for numeric_cast<>
template <>
struct fixed_numeric_limits_base<long long, false>
{
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
BOOST_STATIC_CONSTANT(bool, is_signed = true);
static long long max()
{
# ifdef LONGLONG_MAX
return LONGLONG_MAX;
# else
return 9223372036854775807LL; // hope this is portable
# endif
}
static long long min()
{
# ifdef LONGLONG_MIN
return LONGLONG_MIN;
# else
return -9223372036854775808LL; // hope this is portable
# endif
}
};
template <>
struct fixed_numeric_limits_base<unsigned long long, false>
{
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
BOOST_STATIC_CONSTANT(bool, is_signed = false);
static unsigned long long max()
{
# ifdef ULONGLONG_MAX
return ULONGLONG_MAX;
# else
return 0xffffffffffffffffULL; // hope this is portable
# endif
}
static unsigned long long min() { return 0; }
};
# endif
} // namespace detail
// less_than_type_min -
// x_is_signed should be numeric_limits<X>::is_signed
// y_is_signed should be numeric_limits<Y>::is_signed
// y_min should be numeric_limits<Y>::min()
//
// check(x, y_min) returns true iff x < y_min without invoking comparisons
// between signed and unsigned values.
//
// "poor man's partial specialization" is in use here.
template <bool x_is_signed, bool y_is_signed>
struct less_than_type_min
{
template <class X, class Y>
static bool check(X x, Y y_min)
{ return x < y_min; }
};
template <>
struct less_than_type_min<false, true>
{
template <class X, class Y>
static bool check(X, Y)
{ return false; }
};
template <>
struct less_than_type_min<true, false>
{
template <class X, class Y>
static bool check(X x, Y)
{ return x < 0; }
};
// greater_than_type_max -
// same_sign should be:
// numeric_limits<X>::is_signed == numeric_limits<Y>::is_signed
// y_max should be numeric_limits<Y>::max()
//
// check(x, y_max) returns true iff x > y_max without invoking comparisons
// between signed and unsigned values.
//
// "poor man's partial specialization" is in use here.
template <bool same_sign, bool x_is_signed>
struct greater_than_type_max;
template<>
struct greater_than_type_max<true, true>
{
template <class X, class Y>
static inline bool check(X x, Y y_max)
{ return x > y_max; }
};
template <>
struct greater_than_type_max<false, true>
{
// What does the standard say about this? I think it's right, and it
// will work with every compiler I know of.
template <class X, class Y>
static inline bool check(X x, Y)
{ return x >= 0 && static_cast<X>(static_cast<Y>(x)) != x; }
# if defined(BOOST_MSVC) && BOOST_MSVC <= 1200
// MSVC6 can't static_cast unsigned __int64 -> floating types
# define BOOST_UINT64_CAST(src_type) \
static inline bool check(src_type x, unsigned __int64) \
{ \
if (x < 0) return false; \
unsigned __int64 y = static_cast<unsigned __int64>(x); \
bool odd = y & 0x1; \
__int64 div2 = static_cast<__int64>(y >> 1); \
return ((static_cast<src_type>(div2) * 2.0) + odd) != x; \
}
BOOST_UINT64_CAST(long double);
BOOST_UINT64_CAST(double);
BOOST_UINT64_CAST(float);
# undef BOOST_UINT64_CAST
# endif
};
template<>
struct greater_than_type_max<true, false>
{
template <class X, class Y>
static inline bool check(X x, Y y_max)
{ return x > y_max; }
};
template <>
struct greater_than_type_max<false, false>
{
// What does the standard say about this? I think it's right, and it
// will work with every compiler I know of.
template <class X, class Y>
static inline bool check(X x, Y)
{ return static_cast<X>(static_cast<Y>(x)) != x; }
};
#else // use #pragma hacks if available
namespace detail
{
# if BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4018)
# pragma warning(disable : 4146)
#elif defined(__BORLANDC__)
# pragma option push -w-8041
# endif
// Move to namespace boost in utility.hpp?
template <class T>
struct fixed_numeric_limits : public std::numeric_limits<T>
{
static inline T min()
{
return std::numeric_limits<T>::is_signed && std::numeric_limits<T>::min() >= 0
? T(-std::numeric_limits<T>::max()) : std::numeric_limits<T>::min();
}
};
# if BOOST_MSVC
# pragma warning(pop)
#elif defined(__BORLANDC__)
# pragma option pop
# endif
} // namespace detail
#endif
template<typename Target, typename Source>
inline Target numeric_cast(Source arg BOOST_EXPLICIT_DEFAULT_TARGET)
{
// typedefs abbreviating respective trait classes
typedef detail::fixed_numeric_limits<Source> arg_traits;
typedef detail::fixed_numeric_limits<Target> result_traits;
#if defined(BOOST_STRICT_CONFIG) \
|| (!defined(__HP_aCC) || __HP_aCC > 33900) \
&& (!defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) \
|| defined(BOOST_SGI_CPP_LIMITS))
// typedefs that act as compile time assertions
// (to be replaced by boost compile time assertions
// as and when they become available and are stable)
typedef bool argument_must_be_numeric[arg_traits::is_specialized];
typedef bool result_must_be_numeric[result_traits::is_specialized];
const bool arg_is_signed = arg_traits::is_signed;
const bool result_is_signed = result_traits::is_signed;
const bool same_sign = arg_is_signed == result_is_signed;
if (less_than_type_min<arg_is_signed, result_is_signed>::check(arg, result_traits::min())
|| greater_than_type_max<same_sign, arg_is_signed>::check(arg, result_traits::max())
)
#else // We need to use #pragma hacks if available
# if BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4018)
#elif defined(__BORLANDC__)
#pragma option push -w-8012
# endif
if ((arg < 0 && !result_traits::is_signed) // loss of negative range
|| (arg_traits::is_signed && arg < result_traits::min()) // underflow
|| arg > result_traits::max()) // overflow
# if BOOST_MSVC
# pragma warning(pop)
#elif defined(__BORLANDC__)
#pragma option pop
# endif
#endif
{
throw bad_numeric_cast();
}
return static_cast<Target>(arg);
} // numeric_cast
# undef BOOST_EXPLICIT_DEFAULT_TARGET
} // namespace boost
#endif // BOOST_CAST_HPP
+38
View File
@@ -0,0 +1,38 @@
// Copyright David Abrahams 2003.
// 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_IMPLICIT_CAST_DWA200356_HPP
#define BOOST_IMPLICIT_CAST_DWA200356_HPP
#include <boost/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
namespace boost {
namespace detail {
template<class T> struct icast_identity
{
using type = T;
};
} // namespace detail
// implementation originally suggested by C. Green in
// http://lists.boost.org/MailArchives/boost/msg00886.php
// The use of identity creates a non-deduced form, so that the
// explicit template argument must be supplied
template <typename T>
constexpr T implicit_cast (typename boost::detail::icast_identity<T>::type x) {
return x;
}
} // namespace boost
#endif // BOOST_IMPLICIT_CAST_DWA200356_HPP
-207
View File
@@ -1,207 +0,0 @@
#ifndef BOOST_LEXICAL_CAST_INCLUDED
#define BOOST_LEXICAL_CAST_INCLUDED
// Boost lexical_cast.hpp header -------------------------------------------//
//
// See http://www.boost.org for most recent version including documentation.
// See end of this header for rights and permissions.
//
// what: lexical_cast custom keyword cast
// who: contributed by Kevlin Henney,
// enhanced with contributions from Terje Slettebø,
// with additional fixes and suggestions from Gennaro Prota,
// Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov,
// and other Boosters
// when: November 2000, March 2003
#include <string>
#include <typeinfo>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/type_traits/is_pointer.hpp>
#ifdef BOOST_NO_STRINGSTREAM
#include <strstream>
#else
#include <sstream>
#endif
#if defined(BOOST_NO_STRINGSTREAM) || \
defined(BOOST_NO_STD_WSTRING) || \
defined(BOOST_NO_STD_LOCALE) || \
defined(BOOST_NO_CWCHAR) || \
defined(BOOST_MSVC) && (BOOST_MSVC <= 1200)
#define DISABLE_WIDE_CHAR_SUPPORT
#endif
#ifdef BOOST_NO_INTRINSIC_WCHAR_T
#include <cwchar>
#endif
namespace boost
{
// exception used to indicate runtime lexical_cast failure
class bad_lexical_cast : public std::bad_cast
{
public:
virtual ~bad_lexical_cast() throw()
{
}
};
namespace detail // actual underlying concrete exception type
{
template<typename Target, typename Source>
class no_lexical_conversion : public bad_lexical_cast
{
public:
no_lexical_conversion()
: description(
std::string() + "bad lexical cast: " +
"source type value could not be interpreted as target, Target=" +
typeid(Target).name() + ", Source=" + typeid(Source).name())
{
}
virtual ~no_lexical_conversion() throw()
{
}
virtual const char *what() const throw()
{
return description.c_str();
}
private:
const std::string description; // static initialization fails on MSVC6
};
}
namespace detail // selectors for choosing stream character type
{
template<typename Type>
struct stream_char
{
typedef char type;
};
#ifndef DISABLE_WIDE_CHAR_SUPPORT
template<>
struct stream_char<wchar_t>
{
typedef wchar_t type;
};
template<>
struct stream_char<wchar_t *>
{
typedef wchar_t type;
};
template<>
struct stream_char<const wchar_t *>
{
typedef wchar_t type;
};
template<>
struct stream_char<std::wstring>
{
typedef wchar_t type;
};
#endif
template<typename TargetChar, typename SourceChar>
struct widest_char
{
typedef TargetChar type;
};
template<>
struct widest_char<char, wchar_t>
{
typedef wchar_t type;
};
}
namespace detail // stream wrapper for handling lexical conversions
{
template<typename Target, typename Source>
class lexical_stream
{
public:
lexical_stream()
{
stream.unsetf(std::ios::skipws);
if(std::numeric_limits<Target>::is_specialized)
stream.precision(std::numeric_limits<Target>::digits10 + 1);
else if(std::numeric_limits<Source>::is_specialized)
stream.precision(std::numeric_limits<Source>::digits10 + 1);
}
~lexical_stream()
{
#if defined(BOOST_NO_STRINGSTREAM)
stream.freeze(false);
#endif
}
bool operator<<(const Source &input)
{
return stream << input;
}
template<typename InputStreamable>
bool operator>>(InputStreamable &output)
{
return !is_pointer<InputStreamable>::value &&
stream >> output &&
(stream >> std::ws).eof();
}
bool operator>>(std::string &output)
{
#if defined(BOOST_NO_STRINGSTREAM)
stream << '\0';
#endif
output = stream.str();
return true;
}
#ifndef DISABLE_WIDE_CHAR_SUPPORT
bool operator>>(std::wstring &output)
{
output = stream.str();
return true;
}
#endif
private:
typedef typename widest_char<
typename stream_char<Target>::type,
typename stream_char<Source>::type>::type char_type;
#if defined(BOOST_NO_STRINGSTREAM)
std::strstream stream;
#elif defined(BOOST_NO_STD_LOCALE)
std::stringstream stream;
#else
std::basic_stringstream<char_type> stream;
#endif
};
}
template<typename Target, typename Source>
Target lexical_cast(Source arg)
{
detail::lexical_stream<Target, Source> interpreter;
Target result;
if(!(interpreter << arg && interpreter >> result))
throw detail::no_lexical_conversion<Target, Source>();
return result;
}
}
// Copyright Kevlin Henney, 2000-2003. All rights reserved.
//
// Permission to use, copy, modify, and distribute this software for any
// purpose is hereby granted without fee, provided that this copyright and
// permissions notice appear in all copies and derivatives.
//
// This software is provided "as is" without express or implied warranty.
#undef DISABLE_WIDE_CHAR_SUPPORT
#endif
+132
View File
@@ -0,0 +1,132 @@
// boost polymorphic_cast.hpp header file ----------------------------------------------//
// (C) Copyright Kevlin Henney and Dave Abrahams 1999.
// (C) Copyright Boris Rasin 2014.
// 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)
// See http://www.boost.org/libs/conversion for Documentation.
// Revision History
// 10 Nov 14 polymorphic_pointer_downcast moved to a separate header,
// minor improvements to stisfy latest Boost coding style
// 08 Nov 14 Add polymorphic_pointer_downcast (Boris Rasin)
// 09 Jun 14 "cast.hpp" was renamed to "polymorphic_cast.hpp" and
// inclusion of numeric_cast was removed (Antony Polukhin)
// 23 Jun 05 numeric_cast removed and redirected to the new version (Fernando Cacciola)
// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included
// <boost/limits.hpp> instead (the workaround did not
// actually compile when BOOST_NO_LIMITS was defined in
// any case, so we loose nothing). (John Maddock)
// 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never
// worked with stock GCC; trying to get it to do that broke
// vc-stlport.
// 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp.
// Removed unused BOOST_EXPLICIT_TARGET macro. Moved
// boost::detail::type to boost/type.hpp. Made it compile with
// stock gcc again (Dave Abrahams)
// 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal
// Review (Beman Dawes)
// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams)
// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC
// (Dave Abrahams)
// 30 Jun 00 More MSVC6 workarounds. See comments below. (Dave Abrahams)
// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes)
// 27 Jun 00 More MSVC6 workarounds
// 15 Jun 00 Add workarounds for MSVC6
// 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov)
// 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar)
// 29 Dec 99 Change using declarations so usages in other namespaces work
// correctly (Dave Abrahams)
// 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors
// as suggested Darin Adler and improved by Valentin Bonnard.
// 2 Sep 99 Remove controversial asserts, simplify, rename.
// 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast,
// place in nested namespace.
// 3 Aug 99 Initial version
#ifndef BOOST_POLYMORPHIC_CAST_HPP
#define BOOST_POLYMORPHIC_CAST_HPP
#include <boost/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
# include <boost/assert.hpp>
# include <boost/throw_exception.hpp>
# include <memory> // std::addressof
# include <typeinfo>
# include <type_traits>
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201907L
#define BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST constexpr
#else
#define BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST inline
#endif
namespace boost
{
// See the documentation for descriptions of how to choose between
// static_cast<>, dynamic_cast<>, polymorphic_cast<> and polymorphic_downcast<>
// polymorphic_cast --------------------------------------------------------//
// Runtime checked polymorphic downcasts and crosscasts.
// Suggested in The C++ Programming Language, 3rd Ed, Bjarne Stroustrup,
// section 15.8 exercise 1, page 425.
template <class Target, class Source>
BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST Target polymorphic_cast(Source* x)
{
Target tmp = dynamic_cast<Target>(x);
if ( tmp == 0 ) boost::throw_exception( std::bad_cast() );
return tmp;
}
// polymorphic_downcast ----------------------------------------------------//
// BOOST_ASSERT() checked raw pointer polymorphic downcast. Crosscasts prohibited.
// WARNING: Because this cast uses BOOST_ASSERT(), it violates
// the One Definition Rule if used in multiple translation units
// where BOOST_DISABLE_ASSERTS, BOOST_ENABLE_ASSERT_HANDLER
// NDEBUG are defined inconsistently.
// Contributed by Dave Abrahams
template <class Target, class Source>
BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST Target polymorphic_downcast(Source* x)
{
BOOST_ASSERT( dynamic_cast<Target>(x) == x ); // detect logic error
return static_cast<Target>(x);
}
// BOOST_ASSERT() checked reference polymorphic downcast. Crosscasts prohibited.
// WARNING: Because this cast uses BOOST_ASSERT(), it violates
// the One Definition Rule if used in multiple translation units
// where BOOST_DISABLE_ASSERTS, BOOST_ENABLE_ASSERT_HANDLER
// NDEBUG are defined inconsistently.
// Contributed by Julien Delacroix
template <class Target, class Source>
BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST typename std::enable_if<
std::is_reference<Target>::value, Target
>::type polymorphic_downcast(Source& x)
{
using target_pointer_type = typename std::remove_reference<Target>::type*;
return *boost::polymorphic_downcast<target_pointer_type>(
std::addressof(x)
);
}
} // namespace boost
#undef BOOST_CONVERSION_IMPL_CONSTEXPR_DYN_CAST
#endif // BOOST_POLYMORPHIC_CAST_HPP
@@ -0,0 +1,60 @@
// boost polymorphic_pointer_cast.hpp header file ----------------------------------------------//
// (C) Copyright Boris Rasin, 2014-2021.
// (C) 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)
// See http://www.boost.org/libs/conversion for Documentation.
#ifndef BOOST_CONVERSION_POLYMORPHIC_POINTER_CAST_HPP
#define BOOST_CONVERSION_POLYMORPHIC_POINTER_CAST_HPP
#include <boost/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
# include <boost/assert.hpp>
# include <boost/pointer_cast.hpp>
# include <boost/throw_exception.hpp>
namespace boost
{
// See the documentation for descriptions of how to choose between
// static_pointer_cast<>, dynamic_pointer_cast<>, polymorphic_pointer_cast<> and polymorphic_pointer_downcast<>
// polymorphic_pointer_downcast --------------------------------------------//
// BOOST_ASSERT() checked polymorphic downcast. Crosscasts prohibited.
// Supports any type with static_pointer_cast/dynamic_pointer_cast functions:
// built-in pointers, std::shared_ptr, boost::shared_ptr, boost::intrusive_ptr, etc.
// WARNING: Because this cast uses BOOST_ASSERT(), it violates
// the One Definition Rule if used in multiple translation units
// where BOOST_DISABLE_ASSERTS, BOOST_ENABLE_ASSERT_HANDLER
// NDEBUG are defined inconsistently.
// Contributed by Boris Rasin
template <typename Target, typename Source>
inline auto polymorphic_pointer_downcast (const Source& x)
-> decltype(static_pointer_cast<Target>(x))
{
BOOST_ASSERT(dynamic_pointer_cast<Target> (x) == x);
return static_pointer_cast<Target> (x);
}
template <typename Target, typename Source>
inline auto polymorphic_pointer_cast (const Source& x)
-> decltype(dynamic_pointer_cast<Target>(x))
{
auto tmp = dynamic_pointer_cast<Target> (x);
if ( !tmp ) boost::throw_exception( std::bad_cast() );
return tmp;
}
} // namespace boost
#endif // BOOST_CONVERSION_POLYMORPHIC_POINTER_CAST_HPP
-39
View File
@@ -1,39 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Boost Conversion Library</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><img border="0" src="../../c++boost.gif" align="center" width="277" height="86">Boost
Conversion Library</h1>
<p>The Conversion Library improves program safety and clarity by performing
otherwise messy conversions.&nbsp; It includes cast-style function templates designed to complement the C++
Standard's built-in casts.</p>
<p>To reduce coupling, particularly to standard library IOStreams, the Boost
Conversion Library is
supplied by several headers:</p>
<ul>
<li>The <a href="cast.htm">boost/cast</a> header provides <b>polymorphic_cast&lt;&gt;</b>
and <b>polymorphic_downcast&lt;&gt;</b> to perform safe casting between
polymorphic types, and <b> numeric_cast</b><i>&lt;&gt;</i> to perform safe casting
between numeric types.<br>
</li>
<li>The <a href="lexical_cast.htm">boost/lexical_cast</a> header provides <b>lexical_cast&lt;&gt;</b>
general literal text conversions, such as an <code>int</code> represented as
a <code>string</code>, or vice-versa.</li>
</ul>
<hr>
<p>Revised <!--webbot bot="Timestamp" S-Type="EDITED"
S-Format="%d %B, %Y" startspan -->06 January, 2001<!--webbot bot="Timestamp" endspan i-checksum="38320" -->
</p>
</body>
</html>
+39
View File
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<!--
Copyright (c) 2016 Mikhail Maximov
vigorous.activity at gmail dot com
Copyright (c) Antony Polukhin, 2021-2026
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://boost.org/LICENSE_1_0.txt)
boost-no-inspect
-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=../../doc/html/conversion.html">
<title>Boost.Conversion</title>
<style>
body {
background: #fff;
color: #000;
}
a {
color: #00f;
text-decoration: none;
}
</style>
</head>
<body>
<p>
Automatic redirection failed, please go to
<a href="../../doc/html/conversion.html">../../doc/html/conversion.html</a>
</p>
<p>
&copy; Antony Polukhin, 2014-2024
</p>
</body>
</html>
-223
View File
@@ -1,223 +0,0 @@
<!-- saved from url=(0022)http://internet.e-mail -->
<!doctype html public "-//W3C//DTD HTML Transitional 4.0//EN">
<html>
<head>
<title>lexical_cast</title>
<meta name="author" content="Kevlin Henney, mailto:kevlin@curbralan.com">
<meta name="generator" content="Microsoft FrontPage 4.0">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" align="center" width="277" height="86">Header
<a href="../../boost/lexical_cast.hpp">boost/lexical_cast.hpp</a></h1>
<ul type="square">
<li>
<a href="#motivation">Motivation</a></li>
<li>
<a href="#examples">Examples</a></li>
<li>
<a href="#synopsis">Synopsis</a></li>
<li>
<a href="#lexical_cast"><code>lexical_cast</code></a></li>
<li>
<a href="#bad_lexical_cast"><code>bad_lexical_cast</code></a></li>
<li>
<a href="#changes">Changes</a></li>
</ul>
<hr>
<h2><a name="motivation">Motivation</a></h2>
Sometimes a value must be converted to a literal text form, such as an <code>int</code>
represented as a <code>string</code>, or vice-versa, when a <code>string</code>
is interpreted as an <code>int</code>. Such examples are common when converting
between data types internal to a program and representation external to a
program, such as windows and configuration files.
<p>
The standard C and C++ libraries offer a number of facilities for performing
such conversions. However, they vary with their ease of use, extensibility, and
safety.
<p>
For instance, there are a number of limitations with the family of standard C
functions typified by <code>atoi</code>:
<ul type="square">
<li>
Conversion is supported in one direction only: from text to internal data type.
Converting the other way using the C library requires either the inconvenience
and compromised safety of the <code>sprintf</code> function, or the loss of
portability associated with non-standard functions such as <code>itoa</code>.
</li>
<li>
The range of types supported is only a subset of the built-in numeric types,
namely <code>int</code>, <code>long</code>, and <code>double</code>.
</li>
<li>
The range of types cannot be extended in a uniform manner. For instance,
conversion from string representation to <code>complex</code> or <code>rational</code>.
</li>
</ul>
The standard C functions typified by <code>strtol</code> have the same basic
limitations, but offer finer control over the conversion process. However, for
the common case such control is often either not required or not used. The <code>scanf</code>
family of functions offer even greater control, but also lack safety and ease
of use.
<p>
The standard C++ library offers <code>stringstream</code> for the kind of
in-core formatting being discussed. It offers a great deal of control over the
formatting and conversion of I/O to and from arbitrary types through text.
However, for simple conversions direct use of <code>stringstream</code> can be
either clumsy (with the introduction of extra local variables and the loss of
infix-expression convenience) or obscure (where <code>stringstream</code>
objects are created as temporary objects in an expression). Facets provide a
comprehensive concept and facility for controlling textual representation, but
their perceived complexity and high entry level requires an extreme degree of
involvement for simple conversions, and excludes all but a few programmers.
<p>
The <code>lexical_cast</code> function template offers a convenient and
consistent form for supporting common conversions to and from arbitrary types
when they are represented as text. The simplification it offers is in
expression-level convenience for such conversions. For more involved
conversions, such as where precision or formatting need tighter control than is
offered by the default behavior of <code>lexical_cast</code>, the conventional <code>
stringstream</code> approach is recommended. Where the conversions are
numeric to numeric, <code><a href="cast.htm#numeric_cast">numeric_cast</a></code>
may offer more reasonable behavior than <code>lexical_cast</code>.
<p>
For a good discussion of the options and issues involved in string-based
formatting, including comparison of <code>stringstream</code>, <code>lexical_cast</code>,
and others, see Herb Sutter's article, <a href="http://www.gotw.ca/publications/mill19.htm">
<i>The String Formatters of Manor Farm</i></a>.
<p>
<hr>
<h2><a name="examples">Examples</a></h2>
The following example treats command line arguments as a sequence of numeric
data: <blockquote>
<pre>
int main(int argc, char * argv[])
{
using boost::lexical_cast;
using boost::bad_lexical_cast;
std::vector&lt;short&gt; args;
while(*++argv)
{
try
{
args.push_back(lexical_cast&lt;short&gt;(*argv));
}
catch(bad_lexical_cast &amp;)
{
args.push_back(0);
}
}
...
}
</pre>
</blockquote>The following example uses numeric data in a string expression: <blockquote>
<pre>
void log_message(const std::string &amp;);
void log_errno(int yoko)
{
log_message(&quot;Error &quot; + boost::lexical_cast&lt;std::string&gt;(yoko) + &quot;: &quot; + strerror(yoko));
}
</pre>
</blockquote>
<hr>
<h2><a name="synopsis">Synopsis</a></h2>
Library features defined in <a href="../../boost/lexical_cast.hpp"><code>&quot;boost/lexical_cast.hpp&quot;</code></a>:
<blockquote>
<pre>
namespace boost
{
class <a href="#bad_lexical_cast">bad_lexical_cast</a>;
template&lt;typename Target, typename Source&gt;
Target <a href="#lexical_cast">lexical_cast</a>(Source arg);
}
</pre>
</blockquote>Unit test defined in <a href="lexical_cast_test.cpp"><code>&quot;lexical_cast_test.cpp&quot;</code></a>.
<p>
<hr>
<h2><a name="lexical_cast"><code>lexical_cast</code></a></h2>
<blockquote>
<pre>
template&lt;typename Target, typename Source&gt;
Target lexical_cast(Source arg);
</pre>
</blockquote>Returns the result of streaming <code>arg</code> into a
standard library string-based stream and then out as a <code>Target</code> object.
Where <code>Target</code> is either <code>std::string</code>
or <code>std::wstring</code>, stream extraction takes the whole content
of the string, including spaces, rather than relying on the default
<code>operator&gt;&gt;</code> behavior.
If the conversion is unsuccessful, a <a href="#bad_lexical_cast">
<code>bad_lexical_cast</code></a> exception is thrown.
<p>
The requirements on the argument and result types are:
<ul type="square">
<li>
<code>Source</code> is <i>OutputStreamable</i>, meaning that an <code>operator&lt;&lt;</code>
is defined that takes a <code>std::ostream</code> or <code>std::wostream</code> object on the
left hand side and an instance of the argument type on the right.
</li>
<li>
<code>Target</code> is <i>InputStreamable</i>, meaning that an <code>operator&gt;&gt;</code>
is defined that takes a <code>std::istream</code> or <code>std::wistream</code> object on the left hand side
and an instance of the result type on the right.
</li>
<li>
Both <code>Source</code> and <code>Target</code> are <i>CopyConstructible</i> [20.1.3].
</li>
<li>
<code>Target</code> is <i>DefaultConstructible</i>, meaning that it is possible
to <i>default-initialize</i> an object of that type [8.5, 20.1.4].
</li>
</ul>
The character type of the underlying stream is assumed to be <code>char</code> unless
either the <code>Source</code> or the <code>Target</code> requires wide-character
streaming, in which case the underlying stream uses <code>wchar_t</code>.
<code>Source</code> types that require wide-character streaming are <code>wchar_t</code>,
<code>wchar_t *</code>, and <code>std::wstring</code>. <code>Target</code> types that
require wide-character streaming are <code>wchar_t</code> and <code>std::wstring</code>.
<p>
Where a higher degree of control is required over conversions, <code>std::stringstream</code>
and <code>std::wstringstream</code> offer a more appropriate path. Where non-stream-based conversions are
required, <code>lexical_cast</code>
is the wrong tool for the job and is not special-cased for such scenarios.
<p>
<hr>
<h2><a name="bad_lexical_cast"><code>bad_lexical_cast</code></a></h2>
<blockquote>
<pre>
class bad_lexical_cast : public std::bad_cast
{
public:
... // <i>same member function interface as</i> std::exception
};
</pre>
</blockquote>Exception used to indicate runtime <a href="#lexical_cast"><code>lexical_cast</code></a>
failure.
<hr>
<h2><a name="changes">Changes</a></h2>
<ul type="square">
<li>The previous version of <code>lexical_cast</code> used the default stream precision for reading
and writing floating-point numbers. For numerics that have a corresponding specialization of
<code>std::numeric_limits</code>, the current version now chooses a precision to match.
<li>The previous version of <code>lexical_cast</code> did not support conversion to or from any
wide-character-based types. For compilers with full language and library support for wide characters,
<code>lexical_cast</code> now supports conversions from <code>wchar_t</code>, <code>wchar_t *</code>,
and <code>std::wstring</code> and to <code>wchar_t</code> and <code>std::wstring</code>.
<li>The previous version of <code>lexical_cast</code> assumed that the conventional stream extractor
operators were sufficient for reading values. However, string I/O is asymmetric, with the result
that spaces play the role of I/O separators rather than string content. The current version fixes
this error for <code>std::string</code> and, where supported, <code>std::wstring</code>:
<code>lexical_cast&lt;std::string&gt;("Hello, World")</code> succeeds instead of failing with
a <code>bad_lexical_cast</code> exception.
<li>The previous version of <code>lexical_cast</code> allowed unsafe and meaningless conversions to
pointers. The current version now throws a <code>bad_lexical_cast</code> for conversions to pointers:
<code>lexical_cast&lt;char *&gt;("Goodbye, World")</code> now throws an exception instead of
causing undefined behavior.
</ul>
<p>
<hr>
<div align="right"><small><i>&copy; Copyright Kevlin Henney, 2000&#150;2003</i></small></div>
</body>
</html>
-278
View File
@@ -1,278 +0,0 @@
// Unit test for boost::lexical_cast.
//
// See http://www.boost.org for most recent version, including documentation.
//
// Copyright Terje Slettebø and Kevlin Henney, 2003.
//
// Permission to use, copy, modify, and distribute this software for any
// purpose is hereby granted without fee, provided that this copyright and
// permissions notice appear in all copies and derivatives.
//
// This software is provided "as is" without express or implied warranty.
#include <boost/config.hpp>
#if defined(__INTEL_COMPILER)
#pragma warning(disable: 193 383 488 981 1418 1419)
#elif defined(BOOST_MSVC)
#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800)
#endif
#include <boost/lexical_cast.hpp>
#include <boost/test/floating_point_comparison.hpp>
#include <boost/test/included/unit_test_framework.hpp>
#if defined(BOOST_NO_STRINGSTREAM) || \
defined(BOOST_NO_STD_WSTRING) || \
defined(BOOST_NO_STD_LOCALE) || \
defined(BOOST_NO_CWCHAR) || \
defined(BOOST_MSVC) && (BOOST_MSVC <= 1200)
#define DISABLE_WIDE_CHAR_SUPPORT
#endif
using namespace boost;
void test_conversion_to_char();
void test_conversion_to_int();
void test_conversion_to_double();
void test_conversion_to_bool();
void test_conversion_to_string();
void test_conversion_to_pointer();
void test_conversion_from_wchar_t();
void test_conversion_to_wchar_t();
void test_conversion_from_wstring();
void test_conversion_to_wstring();
unit_test_framework::test_suite *init_unit_test_suite(int, char **)
{
unit_test_framework::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast unit test");
suite->add(BOOST_TEST_CASE(test_conversion_to_char));
suite->add(BOOST_TEST_CASE(test_conversion_to_int));
suite->add(BOOST_TEST_CASE(test_conversion_to_double));
suite->add(BOOST_TEST_CASE(test_conversion_to_bool));
suite->add(BOOST_TEST_CASE(test_conversion_to_pointer));
suite->add(BOOST_TEST_CASE(test_conversion_to_string));
#ifndef DISABLE_WIDE_CHAR_SUPPORT
suite->add(BOOST_TEST_CASE(test_conversion_from_wchar_t));
suite->add(BOOST_TEST_CASE(test_conversion_to_wchar_t));
suite->add(BOOST_TEST_CASE(test_conversion_from_wstring));
suite->add(BOOST_TEST_CASE(test_conversion_to_wstring));
#endif
return suite;
}
void test_conversion_to_char()
{
BOOST_CHECK_EQUAL('A', lexical_cast<char>('A'));
BOOST_CHECK_EQUAL(' ', lexical_cast<char>(' '));
BOOST_CHECK_EQUAL('1', lexical_cast<char>(1));
BOOST_CHECK_EQUAL('0', lexical_cast<char>(0));
BOOST_CHECK_THROW(lexical_cast<char>(123), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL('1', lexical_cast<char>(1.0));
BOOST_CHECK_EQUAL('1', lexical_cast<char>(true));
BOOST_CHECK_EQUAL('0', lexical_cast<char>(false));
BOOST_CHECK_EQUAL('A', lexical_cast<char>("A"));
BOOST_CHECK_EQUAL(' ', lexical_cast<char>(" "));
BOOST_CHECK_THROW(lexical_cast<char>(""), boost::bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<char>("Test"), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL('A', lexical_cast<char>(std::string("A")));
BOOST_CHECK_EQUAL(' ', lexical_cast<char>(std::string(" ")));
BOOST_CHECK_THROW(
lexical_cast<char>(std::string("")), boost::bad_lexical_cast);
BOOST_CHECK_THROW(
lexical_cast<char>(std::string("Test")), boost::bad_lexical_cast);
}
void test_conversion_to_int()
{
BOOST_CHECK_EQUAL(1,lexical_cast<int>('1'));
BOOST_CHECK_EQUAL(0,lexical_cast<int>('0'));
BOOST_CHECK_THROW(lexical_cast<int>('A'),boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(1,lexical_cast<int>(1));
BOOST_CHECK_EQUAL(
std::numeric_limits<int>::max(),
lexical_cast<int>(std::numeric_limits<int>::max()));
BOOST_CHECK_EQUAL(1,lexical_cast<int>(1.0));
BOOST_CHECK_THROW(lexical_cast<int>(1.23), boost::bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<int>(1e20), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(1, lexical_cast<int>(true));
BOOST_CHECK_EQUAL(0, lexical_cast<int>(false));
BOOST_CHECK_EQUAL(123, lexical_cast<int>("123"));
BOOST_CHECK_THROW(
lexical_cast<int>(" 123"), boost::bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<int>(""), boost::bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<int>("Test"), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(123, lexical_cast<int>("123"));
BOOST_CHECK_EQUAL(123,lexical_cast<int>(std::string("123")));
BOOST_CHECK_THROW(
lexical_cast<int>(std::string(" 123")), boost::bad_lexical_cast);
BOOST_CHECK_THROW(
lexical_cast<int>(std::string("")), boost::bad_lexical_cast);
BOOST_CHECK_THROW(
lexical_cast<int>(std::string("Test")), boost::bad_lexical_cast);
}
void test_conversion_to_double()
{
BOOST_CHECK_EQUAL(1.0, lexical_cast<double>('1'));
BOOST_CHECK_THROW(lexical_cast<double>('A'), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(1.0, lexical_cast<double>(1));
BOOST_CHECK_EQUAL(1.23, lexical_cast<double>(1.23));
BOOST_CHECK_CLOSE(
std::numeric_limits<double>::max() / 2,
lexical_cast<double>(std::numeric_limits<double>::max() / 2),
std::numeric_limits<double>::epsilon());
BOOST_CHECK_EQUAL(1.0, lexical_cast<double>(true));
BOOST_CHECK_EQUAL(0.0, lexical_cast<double>(false));
BOOST_CHECK_EQUAL(1.23, lexical_cast<double>("1.23"));
BOOST_CHECK_THROW(lexical_cast<double>(""), boost::bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<double>("Test"), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(1.23, lexical_cast<double>(std::string("1.23")));
BOOST_CHECK_THROW(
lexical_cast<double>(std::string("")), boost::bad_lexical_cast);
BOOST_CHECK_THROW(
lexical_cast<double>(std::string("Test")), boost::bad_lexical_cast);
}
void test_conversion_to_bool()
{
BOOST_CHECK_EQUAL(true, lexical_cast<bool>('1'));
BOOST_CHECK_EQUAL(false, lexical_cast<bool>('0'));
BOOST_CHECK_THROW(lexical_cast<bool>('A'), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(true, lexical_cast<bool>(1));
BOOST_CHECK_EQUAL(false, lexical_cast<bool>(0));
BOOST_CHECK_THROW(lexical_cast<bool>(123), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(true, lexical_cast<bool>(1.0));
BOOST_CHECK_EQUAL(false, lexical_cast<bool>(0.0));
BOOST_CHECK_EQUAL(true, lexical_cast<bool>(true));
BOOST_CHECK_EQUAL(false, lexical_cast<bool>(false));
BOOST_CHECK_EQUAL(true, lexical_cast<bool>("1"));
BOOST_CHECK_EQUAL(false, lexical_cast<bool>("0"));
BOOST_CHECK_THROW(lexical_cast<bool>(""), boost::bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<bool>("Test"), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(true, lexical_cast<bool>("1"));
BOOST_CHECK_EQUAL(false, lexical_cast<bool>("0"));
BOOST_CHECK_EQUAL(true, lexical_cast<bool>(std::string("1")));
BOOST_CHECK_EQUAL(false, lexical_cast<bool>(std::string("0")));
BOOST_CHECK_THROW(
lexical_cast<bool>(std::string("")), boost::bad_lexical_cast);
BOOST_CHECK_THROW(
lexical_cast<bool>(std::string("Test")), boost::bad_lexical_cast);
}
void test_conversion_to_string()
{
BOOST_CHECK_EQUAL("A", lexical_cast<std::string>('A'));
BOOST_CHECK_EQUAL(" ", lexical_cast<std::string>(' '));
BOOST_CHECK_EQUAL("123", lexical_cast<std::string>(123));
BOOST_CHECK_EQUAL("1.23", lexical_cast<std::string>(1.23));
BOOST_CHECK_EQUAL("1.111111111", lexical_cast<std::string>(1.111111111));
BOOST_CHECK_EQUAL("1",lexical_cast<std::string>(true));
BOOST_CHECK_EQUAL("0",lexical_cast<std::string>(false));
BOOST_CHECK_EQUAL("Test", lexical_cast<std::string>("Test"));
BOOST_CHECK_EQUAL(" ", lexical_cast<std::string>(" "));
BOOST_CHECK_EQUAL("", lexical_cast<std::string>(""));
BOOST_CHECK_EQUAL("Test", lexical_cast<std::string>(std::string("Test")));
BOOST_CHECK_EQUAL(" ", lexical_cast<std::string>(std::string(" ")));
BOOST_CHECK_EQUAL("", lexical_cast<std::string>(std::string("")));
}
void test_conversion_to_pointer()
{
BOOST_CHECK_THROW(lexical_cast<char *>("Test"), boost::bad_lexical_cast);
#ifndef DISABLE_WIDE_CHAR_SUPPORT
BOOST_CHECK_THROW(lexical_cast<wchar_t *>("Test"), boost::bad_lexical_cast);
#endif
}
void test_conversion_from_wchar_t()
{
#ifndef DISABLE_WIDE_CHAR_SUPPORT
BOOST_CHECK_EQUAL(1, lexical_cast<int>(L'1'));
BOOST_CHECK_THROW(lexical_cast<int>(L'A'), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(123, lexical_cast<int>(L"123"));
BOOST_CHECK_THROW(lexical_cast<int>(L""), boost::bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<int>(L"Test"), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(1.0, lexical_cast<double>(L'1'));
BOOST_CHECK_THROW(lexical_cast<double>(L'A'), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(1.23, lexical_cast<double>(L"1.23"));
BOOST_CHECK_THROW(lexical_cast<double>(L""), boost::bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<double>(L"Test"), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(true, lexical_cast<bool>(L'1'));
BOOST_CHECK_EQUAL(false, lexical_cast<bool>(L'0'));
BOOST_CHECK_THROW(lexical_cast<bool>(L'A'), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(true, lexical_cast<bool>(L"1"));
BOOST_CHECK_EQUAL(false, lexical_cast<bool>(L"0"));
BOOST_CHECK_THROW(lexical_cast<bool>(L""), boost::bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<bool>(L"Test"), boost::bad_lexical_cast);
#endif
}
void test_conversion_to_wchar_t()
{
#ifndef DISABLE_WIDE_CHAR_SUPPORT
BOOST_CHECK_EQUAL(L'1', lexical_cast<wchar_t>(1));
BOOST_CHECK_EQUAL(L'0', lexical_cast<wchar_t>(0));
BOOST_CHECK_THROW(lexical_cast<wchar_t>(123), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(L'1', lexical_cast<wchar_t>(1.0));
BOOST_CHECK_EQUAL(L'0', lexical_cast<wchar_t>(0.0));
BOOST_CHECK_EQUAL(L'1', lexical_cast<wchar_t>(true));
BOOST_CHECK_EQUAL(L'0', lexical_cast<wchar_t>(false));
BOOST_CHECK_EQUAL(L'A', lexical_cast<wchar_t>(L'A'));
BOOST_CHECK_EQUAL(L' ', lexical_cast<wchar_t>(L' '));
BOOST_CHECK_EQUAL(L'A', lexical_cast<wchar_t>(L"A"));
BOOST_CHECK_EQUAL(L' ', lexical_cast<wchar_t>(L" "));
BOOST_CHECK_THROW(lexical_cast<wchar_t>(L""), boost::bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<wchar_t>(L"Test"), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(L'A', lexical_cast<wchar_t>(std::wstring(L"A")));
BOOST_CHECK_EQUAL(L' ', lexical_cast<wchar_t>(std::wstring(L" ")));
BOOST_CHECK_THROW(
lexical_cast<wchar_t>(std::wstring(L"")), boost::bad_lexical_cast);
BOOST_CHECK_THROW(
lexical_cast<wchar_t>(std::wstring(L"Test")), boost::bad_lexical_cast);
#endif
}
void test_conversion_from_wstring()
{
#ifndef DISABLE_WIDE_CHAR_SUPPORT
BOOST_CHECK_EQUAL(123, lexical_cast<int>(std::wstring(L"123")));
BOOST_CHECK_THROW(
lexical_cast<int>(std::wstring(L"")), boost::bad_lexical_cast);
BOOST_CHECK_THROW(
lexical_cast<int>(std::wstring(L"Test")), boost::bad_lexical_cast);
BOOST_CHECK_EQUAL(true, lexical_cast<bool>(std::wstring(L"1")));
BOOST_CHECK_EQUAL(false, lexical_cast<bool>(std::wstring(L"0")));
BOOST_CHECK_THROW(
lexical_cast<bool>(std::wstring(L"")), boost::bad_lexical_cast);
BOOST_CHECK_THROW(
lexical_cast<bool>(std::wstring(L"Test")), boost::bad_lexical_cast);
#endif
}
void test_conversion_to_wstring()
{
#ifndef DISABLE_WIDE_CHAR_SUPPORT
BOOST_CHECK(L"123" == lexical_cast<std::wstring>(123));
BOOST_CHECK(L"1.23" == lexical_cast<std::wstring>(1.23));
BOOST_CHECK(L"1.111111111" == lexical_cast<std::wstring>(1.111111111));
BOOST_CHECK(L"1" == lexical_cast<std::wstring>(true));
BOOST_CHECK(L"0" == lexical_cast<std::wstring>(false));
BOOST_CHECK(L"A" == lexical_cast<std::wstring>(L'A'));
BOOST_CHECK(L" " == lexical_cast<std::wstring>(L' '));
BOOST_CHECK(L"Test" == lexical_cast<std::wstring>(L"Test"));
BOOST_CHECK(L" " == lexical_cast<std::wstring>(L" "));
BOOST_CHECK(L"" == lexical_cast<std::wstring>(L""));
BOOST_CHECK(L"Test" == lexical_cast<std::wstring>(std::wstring(L"Test")));
BOOST_CHECK(L" " == lexical_cast<std::wstring>(std::wstring(L" ")));
BOOST_CHECK(L"" == lexical_cast<std::wstring>(std::wstring(L"")));
#endif
}
+16
View File
@@ -0,0 +1,16 @@
{
"key": "conversion",
"name": "Conversion",
"authors": [
"Dave Abrahams",
"Kevlin Henney"
],
"description": "Polymorphic casts.",
"category": [
"Miscellaneous"
],
"maintainers": [
"Antony Polukhin <antoshkka -at- gmail.com>"
],
"cxxstd": "11"
}
-312
View File
@@ -1,312 +0,0 @@
// what: simple unit test framework
// who: developed by Kevlin Henney
// when: November 2000
// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.91
//
// ChangeLog:
// 20 Jan 2001 - Fixed a warning for MSVC (Dave Abrahams)
#ifndef TEST_INCLUDED
#define TEST_INCLUDED
#include <exception>
#include <iostream>
#include <strstream> // for out-of-the-box g++
#include <string>
namespace test // test tuple comprises name and nullary function (object)
{
template<typename string_type, typename function_type>
struct test
{
string_type name;
function_type action;
static test make(string_type name, function_type action)
{
test result; // MSVC aggreggate initializer bugs
result.name = name;
result.action = action;
return result;
}
};
}
namespace test // failure exception used to indicate checked test failures
{
class failure : public std::exception
{
public: // struction (default cases are OK)
failure(const std::string & why)
: reason(why)
{
}
// std::~string has no exception-specification (could throw anything),
// but we need to be compatible with std::~exception's empty one
// see std::15.4p13 and std::15.4p3
~failure() throw()
{
}
public: // usage
virtual const char * what() const throw()
{
return reason.c_str();
}
private: // representation
std::string reason;
};
}
namespace test // not_implemented exception used to mark unimplemented tests
{
class not_implemented : public std::exception
{
public: // usage (default ctor and dtor are OK)
virtual const char * what() const throw()
{
return "not implemented";
}
};
}
namespace test // test utilities
{
inline void check(bool condition, const std::string & description)
{
if(!condition)
{
throw failure(description);
}
}
inline void check_true(bool value, const std::string & description)
{
check(value, "expected true: " + description);
}
inline void check_false(bool value, const std::string & description)
{
check(!value, "expected false: " + description);
}
template<typename lhs_type, typename rhs_type>
void check_equal(
const lhs_type & lhs, const rhs_type & rhs,
const std::string & description)
{
check(lhs == rhs, "expected equal values: " + description);
}
template<typename lhs_type, typename rhs_type>
void check_unequal(
const lhs_type & lhs, const rhs_type & rhs,
const std::string & description)
{
check(lhs != rhs, "expected unequal values: " + description);
}
inline void check_null(const void* ptr, const std::string & description)
{
check(!ptr, "expected null pointer: " + description);
}
inline void check_non_null(const void* ptr, const std::string & description)
{
check(ptr != 0, "expected non-null pointer: " + description);
}
}
#define TEST_CHECK_THROW(expression, exception, description) \
try \
{ \
expression; \
throw ::test::failure(description); \
} \
catch(exception &) \
{ \
}
namespace test // memory tracking (enabled if test new and delete linked in)
{
class allocations
{
public: // singleton access
static allocations & instance()
{
static allocations singleton;
return singleton;
}
public: // logging
void clear()
{
alloc_count = dealloc_count = 0;
}
void allocation()
{
++alloc_count;
}
void deallocation()
{
++dealloc_count;
}
public: // reporting
unsigned long allocated() const
{
return alloc_count;
}
unsigned long deallocated() const
{
return dealloc_count;
}
bool balanced() const
{
return alloc_count == dealloc_count;
}
private: // structors (default dtor is fine)
allocations()
: alloc_count(0), dealloc_count(0)
{
}
private: // prevention
allocations(const allocations &);
allocations & operator=(const allocations &);
private: // state
unsigned long alloc_count, dealloc_count;
};
}
namespace test // tester is the driver class for a sequence of tests
{
template<typename test_iterator>
class tester
{
public: // structors (default destructor is OK)
tester(test_iterator first_test, test_iterator after_last_test)
: begin(first_test), end(after_last_test)
{
}
public: // usage
bool operator()(); // returns true if all tests passed
private: // representation
test_iterator begin, end;
private: // prevention
tester(const tester &);
tester &operator=(const tester &);
};
template<typename test_iterator>
bool tester<test_iterator>::operator()()
{
using namespace std;
unsigned long passed = 0, failed = 0, unimplemented = 0;
for(test_iterator current = begin; current != end; ++current)
{
cerr << "[" << current->name << "] " << flush;
string result = "passed"; // optimistic
try
{
allocations::instance().clear();
current->action();
if(!allocations::instance().balanced())
{
unsigned long allocated = allocations::instance().allocated();
unsigned long deallocated = allocations::instance().deallocated();
ostrstream report;
report << "new/delete ("
<< allocated << " allocated, "
<< deallocated << " deallocated)"
<< ends;
const char * text = report.str();
report.freeze(false);
throw failure(text);
}
++passed;
}
catch(const failure & caught)
{
(result = "failed: ") += caught.what();
++failed;
}
catch(const not_implemented &)
{
result = "not implemented";
++unimplemented;
}
catch(const exception & caught)
{
(result = "exception: ") += caught.what();
++failed;
}
catch(...)
{
result = "failed with unknown exception";
++failed;
}
cerr << result << endl;
}
cerr << passed + failed << " tests: "
<< passed << " passed, "
<< failed << " failed";
if(unimplemented)
{
cerr << " (" << unimplemented << " not implemented)";
}
cerr << endl;
return failed == 0;
}
}
#endif
// Copyright Kevlin Henney, 2000. All rights reserved.
//
// Permission to use, copy, modify, and distribute this software for any
// purpose is hereby granted without fee, provided that this copyright and
// permissions notice appear in all copies and derivatives, and that no
// charge may be made for the software and its documentation except to cover
// cost of distribution.
//
// This software is provided "as is" without express or implied warranty.
+17
View File
@@ -0,0 +1,17 @@
# Copyright (c) 2016-2026 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
include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(NOT HAVE_BOOST_TEST)
return()
endif()
set(BOOST_TEST_LINK_LIBRARIES Boost::conversion Boost::core)
boost_test(TYPE run SOURCES cast_test.cpp)
boost_test(TYPE run SOURCES implicit_cast.cpp)
boost_test(TYPE compile-fail SOURCES implicit_cast_fail.cpp)
boost_test(TYPE compile-fail SOURCES implicit_cast_fail2.cpp)
boost_test(TYPE run SOURCES polymorphic_cast_test.cpp LINK_LIBRARIES Boost::smart_ptr)
+31
View File
@@ -0,0 +1,31 @@
# Copyright (C) 2001-2003 Douglas Gregor
# Copyright (C) Antony Polukhin, 2011-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.0.1 ;
import-search /boost/config/checks ;
import config : requires ;
import testing ;
import feature ;
project
: requirements
<library>/boost/conversion//boost_conversion
[ requires cxx11_decltype ]
# default to all warnings on:
<warnings>all
# set warnings as errors for those compilers we know we get warning free:
<toolset>gcc:<cxxflags>-Wextra
<toolset>gcc:<cxxflags>-Wno-uninitialized
;
test-suite conversion
: [ run implicit_cast.cpp ]
[ compile-fail implicit_cast_fail.cpp ]
[ run cast_test.cpp ]
[ run polymorphic_cast_test.cpp : : : <library>/boost/smart_ptr//boost_smart_ptr ]
[ compile-fail implicit_cast_fail2.cpp ]
;
+87
View File
@@ -0,0 +1,87 @@
# 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)
#
# Copyright Antony Polukhin, 2016-2025.
#
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
# and how it can be used with Boost libraries.
#
# File revision #6
init:
# boost-local/libs/ folder to put this library into. This may be useful, if you're for example running Travis
# from `Boost.DLL` repo while Boost already has `dll` and with to replace `dll` with content of`Boost.DLL`.
#
# Otherwise just leave the default value - set BOOST_LIBS_FOLDER=%APPVEYOR_PROJECT_NAME%
- set BOOST_LIBS_FOLDER=%APPVEYOR_PROJECT_NAME%
###############################################################################################################
# From this point and below code is same for all the Boost libs
###############################################################################################################
version: 1.84.{build}-{branch}
# branches to build
branches:
except:
- gh-pages
skip_tags: true
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1,clang-win
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
before_build:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- echo "Testing %APPVEYOR_PROJECT_NAME%"
# Cloning Boost libraries (fast nondeep cloning)
- set BOOST=C:/boost-local
- git clone -b %BOOST_BRANCH% --depth 10 https://github.com/boostorg/boost.git %BOOST%
- cd %BOOST%
- git submodule update --init --depth 10 tools/build tools/boostdep
- rm -rf %BOOST%/libs/%BOOST_LIBS_FOLDER%
- mv -f %APPVEYOR_BUILD_FOLDER% %BOOST%/libs/%BOOST_LIBS_FOLDER%
- python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 2" %BOOST_LIBS_FOLDER%
build_script:
- cmd /c bootstrap
- b2.exe headers
- cd %BOOST%/libs/%BOOST_LIBS_FOLDER%/test
after_build:
before_test:
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- echo "Running command ..\..\..\b2 -j3 toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release"
- ..\..\..\b2.exe -j3 toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release cxxflags="-DBOOST_TRAVISCI_BUILD"
after_test:
on_success:
on_failure:
on_finish:
+124
View File
@@ -0,0 +1,124 @@
// boost utility cast test program -----------------------------------------//
// (C) Copyright Beman Dawes, Dave Abrahams 1999. 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)
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 28 Set 04 factored out numeric_cast<> test (Fernando Cacciola)
// 20 Jan 01 removed use of <limits> for portability to raw GCC (David Abrahams)
// 28 Jun 00 implicit_cast removed (Beman Dawes)
// 30 Aug 99 value_cast replaced by numeric_cast
// 3 Aug 99 Initial Version
#include <iostream>
#include <boost/polymorphic_cast.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost;
using std::cout;
namespace
{
struct Base
{
virtual char kind() { return 'B'; }
};
struct Base2
{
virtual char kind2() { return '2'; }
};
struct Derived : public Base, Base2
{
virtual char kind() { return 'D'; }
};
}
constexpr bool compile_time_polymorphic_cast_check() {
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201907L
Derived derived;
Base* base = &derived;
return polymorphic_cast<Derived*>(base) != nullptr;
#endif
return true;
}
static_assert(
compile_time_polymorphic_cast_check(),
"polymorphic_cast does not work at compile time"
);
constexpr bool compile_time_polymorphic_downcast_check() {
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201907L
Derived derived;
Base* base = &derived;
return polymorphic_downcast<Derived*>(base) != nullptr;
#endif
return true;
}
static_assert(
compile_time_polymorphic_downcast_check(),
"polymorphic_downcast does not work at compile time"
);
constexpr bool compile_time_polymorphic_downcast2_check() {
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201907L
Derived derived;
Base& base = derived;
Derived& derived_again = polymorphic_downcast<Derived&>(base);
(void)derived_again;
#endif
return true;
}
static_assert(
compile_time_polymorphic_downcast2_check(),
"polymorphic_downcast does not work at compile time"
);
int main( int argc, char * argv[] )
{
# ifdef NDEBUG
cout << "NDEBUG is defined\n";
# else
cout << "NDEBUG is not defined\n";
# endif
cout << "\nBeginning tests...\n";
// test polymorphic_cast ---------------------------------------------------//
// tests which should succeed
Derived derived_instance;
Base * base = &derived_instance;
Derived * derived = polymorphic_downcast<Derived*>( base ); // downcast
BOOST_TEST( derived->kind() == 'D' );
derived = polymorphic_cast<Derived*>( base ); // downcast, throw on error
BOOST_TEST( derived->kind() == 'D' );
Base2 * base2 = polymorphic_cast<Base2*>( base ); // crosscast
BOOST_TEST( base2->kind2() == '2' );
// tests which should result in errors being detected
Base base_instance;
base = &base_instance;
if ( argc > 1 && *argv[1] == '1' )
{ derived = polymorphic_downcast<Derived*>( base ); } // #1 assert failure
bool caught_exception = false;
try { derived = polymorphic_cast<Derived*>( base ); }
catch (const std::bad_cast&)
{ cout<<"caught bad_cast\n"; caught_exception = true; }
BOOST_TEST( caught_exception );
// the following is just so generated code can be inspected
BOOST_TEST( derived->kind() != 'B' );
return boost::report_errors();
} // main
+43
View File
@@ -0,0 +1,43 @@
// Copyright David Abrahams 2003.
// 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/implicit_cast.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/type.hpp>
using boost::implicit_cast;
using boost::type;
template <class T>
type<T> check_return(T) { return type<T>(); }
struct foo
{
foo(char const*) {}
operator long() const { return 0; }
};
using long_type = type<long>;
using foo_type = type<foo>;
int main()
{
type<long> x = check_return(boost::implicit_cast<long>(1));
BOOST_TEST(boost::implicit_cast<long>(1) == 1L);
type<foo> f = check_return(boost::implicit_cast<foo>("hello"));
type<long> z = check_return(boost::implicit_cast<long>(foo("hello")));
// warning suppression:
(void)x;
(void)f;
(void)z;
constexpr long value = boost::implicit_cast<long>(42);
BOOST_TEST(value == 42L);
return boost::report_errors();
}
+20
View File
@@ -0,0 +1,20 @@
// Copyright David Abrahams 2003.
// 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/implicit_cast.hpp>
using boost::implicit_cast;
struct foo
{
explicit foo(char const*) {}
};
int main()
{
foo x = implicit_cast<foo>("foobar");
(void)x; // warning suppression.
return 0;
}
+19
View File
@@ -0,0 +1,19 @@
//
// Test that implicit_cast requires a template argument
//
// Copyright 2014 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/implicit_cast.hpp>
int main()
{
int x = boost::implicit_cast( 1 );
(void)x;
return 0;
}
+383
View File
@@ -0,0 +1,383 @@
//
// Test boost::polymorphic_cast, boost::polymorphic_downcast and
// boost::polymorphic_pointer_cast, boost::polymorphic_pointer_downcast
//
// Copyright 1999 Beman Dawes
// Copyright 1999 Dave Abrahams
// Copyright 2014 Peter Dimov
// Copyright 2014 Boris Rasin, Antony Polukhin
// Copyright 2023 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
//
#define BOOST_ENABLE_ASSERT_HANDLER
#include <boost/polymorphic_cast.hpp>
#include <boost/polymorphic_pointer_cast.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/intrusive_ptr.hpp>
#include <boost/smart_ptr/intrusive_ref_counter.hpp>
#include <boost/core/lightweight_test.hpp>
#include <string>
#include <memory>
static bool expect_assertion = false;
static int assertion_failed_count = 0;
//assertion handler throws it to exit like assert, but to be able to catch it and stop
//usage: BOOST_TEST_THROWS( function_with_assert(), expected_assertion );
struct expected_assertion {};
// BOOST_ASSERT custom handler
void boost::assertion_failed( char const * expr, char const * function, char const * file, long line )
{
if( expect_assertion )
{
++assertion_failed_count;
throw expected_assertion();
}
else
{
BOOST_ERROR( "unexpected assertion" );
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): assertion '" << expr << "' failed in function '"
<< function << "'" << std::endl;
}
}
//
struct Base : boost::intrusive_ref_counter<Base>
{
virtual ~Base() {}
virtual std::string kind() { return "Base"; }
};
struct Base2
{
virtual ~Base2() {}
virtual std::string kind2() { return "Base2"; }
};
struct Derived : public Base, Base2
{
virtual std::string kind() { return "Derived"; }
};
static void test_polymorphic_cast()
{
Base * base = new Derived;
Derived * derived;
try
{
derived = boost::polymorphic_cast<Derived*>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
}
catch( std::bad_cast const& )
{
BOOST_ERROR( "boost::polymorphic_cast<Derived*>( base ) threw std::bad_cast" );
}
Base2 * base2;
try
{
base2 = boost::polymorphic_cast<Base2*>( base ); // crosscast
BOOST_TEST( base2 != 0 );
if( base2 != 0 )
{
BOOST_TEST_EQ( base2->kind2(), "Base2" );
}
}
catch( std::bad_cast const& )
{
BOOST_ERROR( "boost::polymorphic_cast<Base2*>( base ) threw std::bad_cast" );
}
delete base;
}
static void test_polymorphic_pointer_cast()
{
Base * base = new Derived;
Derived * derived;
try
{
derived = boost::polymorphic_pointer_cast<Derived>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
}
catch( std::bad_cast const& )
{
BOOST_ERROR( "boost::polymorphic_pointer_cast<Derived>( base ) threw std::bad_cast" );
}
Base2 * base2;
try
{
base2 = boost::polymorphic_pointer_cast<Base2>( base ); // crosscast
BOOST_TEST( base2 != 0 );
if( base2 != 0 )
{
BOOST_TEST_EQ( base2->kind2(), "Base2" );
}
}
catch( std::bad_cast const& )
{
BOOST_ERROR( "boost::polymorphic_pointer_cast<Base2>( base ) threw std::bad_cast" );
}
boost::shared_ptr<Base> sp_base( base );
boost::shared_ptr<Base2> sp_base2;
try
{
sp_base2 = boost::polymorphic_pointer_cast<Base2>( sp_base ); // crosscast
BOOST_TEST( sp_base2 != 0 );
if( sp_base2 != 0 )
{
BOOST_TEST_EQ( sp_base2->kind2(), "Base2" );
}
}
catch( std::bad_cast const& )
{
BOOST_ERROR( "boost::polymorphic_pointer_cast<Base2>( sp_base ) threw std::bad_cast" );
}
// we do not `delete base;` because sahred_ptr is holding base
}
static void test_polymorphic_downcast()
{
Base *base_pointer = new Derived;
// test raw pointer cast
Derived *derived_pointer = boost::polymorphic_downcast<Derived *>(base_pointer);
BOOST_TEST(derived_pointer != 0);
if (derived_pointer != 0)
{
BOOST_TEST_EQ(derived_pointer->kind(), "Derived");
}
// test reference cast
Derived& derived_ref = boost::polymorphic_downcast<Derived&>(*base_pointer);
BOOST_TEST_EQ(derived_ref.kind(), "Derived");
delete base_pointer;
}
static void test_polymorphic_pointer_downcast_builtin()
{
Base * base = new Derived;
Derived * derived = boost::polymorphic_pointer_downcast<Derived>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
// polymorphic_pointer_downcast can't do crosscasts
delete base;
}
static void test_polymorphic_pointer_downcast_boost_shared()
{
boost::shared_ptr<Base> base (new Derived);
boost::shared_ptr<Derived> derived = boost::polymorphic_pointer_downcast<Derived>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
}
static void test_polymorphic_pointer_downcast_intrusive()
{
boost::intrusive_ptr<Base> base (new Derived);
boost::intrusive_ptr<Derived> derived = boost::polymorphic_pointer_downcast<Derived>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
}
static void test_polymorphic_pointer_downcast_std_shared()
{
std::shared_ptr<Base> base (new Derived);
std::shared_ptr<Derived> derived = boost::polymorphic_pointer_downcast<Derived>( base );
BOOST_TEST( derived != 0 );
if( derived != 0 )
{
BOOST_TEST_EQ( derived->kind(), "Derived" );
}
}
static void test_polymorphic_cast_fail()
{
Base * base = new Base;
BOOST_TEST_THROWS( boost::polymorphic_cast<Derived*>( base ), std::bad_cast );
delete base;
}
static void test_polymorphic_pointer_cast_fail()
{
Base * base = new Base;
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( base ), std::bad_cast );
delete base;
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( boost::shared_ptr<Base>(new Base) ), std::bad_cast );
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( std::shared_ptr<Base>(new Base) ), std::bad_cast );
BOOST_TEST_THROWS( boost::polymorphic_pointer_cast<Derived>( boost::intrusive_ptr<Base>(new Base) ), std::bad_cast );
}
static void test_polymorphic_downcast_fail()
{
Base * base_pointer = new Base;
{
// test raw pointer cast
int old_count = assertion_failed_count;
expect_assertion = true;
BOOST_TEST_THROWS(boost::polymorphic_downcast<Derived *>(base_pointer), expected_assertion); // should assert
BOOST_TEST_EQ(assertion_failed_count, old_count + 1);
expect_assertion = false;
}
{
// test reference cast
int old_count = assertion_failed_count;
expect_assertion = true;
BOOST_TEST_THROWS(boost::polymorphic_downcast<Derived &>(*base_pointer), expected_assertion); // should assert
BOOST_TEST_EQ(assertion_failed_count, old_count + 1);
expect_assertion = false;
}
delete base_pointer;
}
static void test_polymorphic_pointer_downcast_builtin_fail()
{
Base * base = new Base;
int old_count = assertion_failed_count;
expect_assertion = true;
BOOST_TEST_THROWS( boost::polymorphic_pointer_downcast<Derived>( base ), expected_assertion ); // should assert
BOOST_TEST_EQ( assertion_failed_count, old_count + 1 );
expect_assertion = false;
delete base;
}
static void test_polymorphic_pointer_downcast_boost_shared_fail()
{
boost::shared_ptr<Base> base (new Base);
int old_count = assertion_failed_count;
expect_assertion = true;
BOOST_TEST_THROWS( boost::polymorphic_pointer_downcast<Derived>( base ), expected_assertion ); // should assert
BOOST_TEST_EQ( assertion_failed_count, old_count + 1 );
expect_assertion = false;
}
static void test_polymorphic_pointer_downcast_std_shared_fail()
{
std::shared_ptr<Base> base (new Base);
int old_count = assertion_failed_count;
expect_assertion = true;
BOOST_TEST_THROWS( boost::polymorphic_pointer_downcast<Derived>( base ), expected_assertion ); // should assert
BOOST_TEST_EQ( assertion_failed_count, old_count + 1 );
expect_assertion = false;
}
static void test_polymorphic_pointer_downcast_intrusive_fail()
{
boost::intrusive_ptr<Base> base (new Base);
int old_count = assertion_failed_count;
expect_assertion = true;
BOOST_TEST_THROWS( boost::polymorphic_pointer_downcast<Derived>( base ), expected_assertion); // should assert
BOOST_TEST_EQ( assertion_failed_count, old_count + 1 );
expect_assertion = false;
}
int main()
{
test_polymorphic_cast();
test_polymorphic_pointer_cast();
test_polymorphic_downcast();
test_polymorphic_pointer_downcast_builtin();
test_polymorphic_pointer_downcast_boost_shared();
test_polymorphic_pointer_downcast_intrusive();
test_polymorphic_cast_fail();
test_polymorphic_pointer_cast_fail();
test_polymorphic_downcast_fail();
test_polymorphic_pointer_downcast_builtin_fail();
test_polymorphic_pointer_downcast_boost_shared_fail();
test_polymorphic_pointer_downcast_intrusive_fail();
test_polymorphic_pointer_downcast_std_shared();
test_polymorphic_pointer_downcast_std_shared_fail();
return boost::report_errors();
}