-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from cppalliance/develop
Merge review week 1 changes to master
- Loading branch information
Showing
20 changed files
with
377 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//// | ||
Copyright 2024 Matt Borland | ||
Distributed under the Boost Software License, Version 1.0. | ||
https://www.boost.org/LICENSE_1_0.txt | ||
//// | ||
|
||
= Limits | ||
:idprefix: limits_ | ||
|
||
== Limits overview | ||
|
||
The contents of `<boost/charconv/limits.hpp>` are designed to help the user optimize the size of the buffer required for `to_chars`. | ||
|
||
[source, c++] | ||
---- | ||
namespace boost { namespace charconv { | ||
template <typename T> | ||
constexpr int limits<T>::max_chars10; | ||
template <typename T> | ||
constexpr int limits<T>::max_chars; | ||
}} // Namespace boost::charconv | ||
---- | ||
|
||
=== max_chars10 | ||
|
||
The minimum size of the buffer that needs to be | ||
passed to `to_chars` to guarantee successful conversion for all values of type T, when either no base is passed, or base 10 is passed. | ||
|
||
=== max_chars | ||
|
||
The minimum size of the buffer that needs to be passed to `to_chars` to guarantee successful conversion for all values of type T, for any value of base. | ||
|
||
== Examples | ||
|
||
[source, c++] | ||
---- | ||
char buffer [boost::charconv::limits<std::int32_t>::max_chars10; | ||
auto r = boost::charconv::to_chars(buffer, buffer + sizeof(buffer), std::numeric_limits<std::int32_t>::max()); | ||
assert(r.ec == std::errc()); | ||
assert(r); // Same as above but less verbose. Added in C++26. | ||
assert(!strcmp(buffer, "2147483647")); // strcmp returns 0 on match | ||
---- | ||
|
||
[source, c++] | ||
---- | ||
char buffer [boost::charconv::limits<float>::max_chars10; | ||
auto r = boost::charconv::to_chars(buffer, buffer + sizeof(buffer), std::numeric_limits<float>::max()); | ||
assert(r.ec == std::errc()); | ||
assert(r); // Same as above but less verbose. Added in C++26. | ||
assert(!strcmp(buffer, "3.40282347e+38")); // strcmp returns 0 on match | ||
---- | ||
|
||
[source, c++] | ||
---- | ||
char buffer [boost::charconv::limits<std::uint16_t>::max_chars; | ||
auto r = boost::charconv::to_chars(buffer, buffer + sizeof(buffer), std::numeric_limits<std::uint16_t>::max(), 2); | ||
assert(r.ec == std::errc()); | ||
assert(r); // Same as above but less verbose. Added in C++26. | ||
assert(!strcmp(buffer, "1111111111111111")); // strcmp returns 0 on match | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.