From 0af8de5509db2c0f027e136578e1cb96011b915a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 9 Jan 2026 16:15:39 +0200 Subject: [PATCH] Update documentation --- doc/uuid/changes.adoc | 1 + doc/uuid/string_generator.adoc | 4 ++-- doc/uuid/uuid_io.adoc | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/doc/uuid/changes.adoc b/doc/uuid/changes.adoc index 04845eb..8604082 100644 --- a/doc/uuid/changes.adoc +++ b/doc/uuid/changes.adoc @@ -11,6 +11,7 @@ * Most `uuid` accessors, operations, and `to_chars` are now `constexpr` when possible (on {cpp}14 and higher and on recent compilers). * Added SIMD implementation of `to_chars`, which can offer up to 5.5x performance improvement in UUID formatting. (Andrey Semashev) * Added SIMD implementation of `from_chars`, which can offer up to 13x performance improvement in UUID parsing. (Andrey Semashev) +* Added `uuid_from_string` to `boost/uuid/uuid_io.hpp`. == Changes in Boost 1.90.0 diff --git a/doc/uuid/string_generator.adoc b/doc/uuid/string_generator.adoc index 6fa3ed6..423504d 100644 --- a/doc/uuid/string_generator.adoc +++ b/doc/uuid/string_generator.adoc @@ -25,7 +25,7 @@ struct string_generator template constexpr uuid operator()( CharIterator first, CharIterator last, - int& pos, from_chars_error& err ) const noexcept; + std::ptrdiff_t& pos, from_chars_error& err ) const noexcept; }; }} // namespace boost::uuids @@ -120,7 +120,7 @@ uuid u2 = gen( s2.begin(), s2.end() ); ``` template constexpr uuid operator()( CharIterator first, CharIterator last, - int& pos, from_chars_error& err ) const noexcept; + std::ptrdiff_t& pos, from_chars_error& err ) const noexcept; ``` Requires: :: `CharIterator` must be an input iterator with a character value type (one of `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t`). diff --git a/doc/uuid/uuid_io.adoc b/doc/uuid/uuid_io.adoc index 1d77d00..ac5a056 100644 --- a/doc/uuid/uuid_io.adoc +++ b/doc/uuid/uuid_io.adoc @@ -63,6 +63,11 @@ template constexpr from_chars_result from_chars( Ch const* first, Ch const* last, uuid& u ) noexcept; +// uuid_from_string + +template constexpr uuid uuid_from_string( Ch const* str ); +template constexpr uuid uuid_from_string( Str const& str ); + }} // namespace boost::uuids ---- @@ -269,3 +274,32 @@ Effects: :: NOTE: The values `from_chars_error::closing_brace_expected` and `from_chars_error::unexpected_extra_input` are never returned by `from_chars`. They can be returned from the nonthrowing `string_generator::operator()` overload. + +=== uuid_from_string + +``` +template constexpr uuid uuid_from_string( Ch const* str ); +``` + +Requires: :: `Ch` must be a character type (one of `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t`). + +Effects: :: + Parses a `uuid` string representation from the characters in the range `[str, str + std::char_traits::length(str))` and stores the result in `u`. + On error, throws `std::runtime_error`. + +NOTE: Unlike `from_chars`, this function does not allow extra input; if after a complete UUID is parsed, unconsumed characters remain, an exception is thrown. + +``` +template constexpr uuid uuid_from_string( Str const& str ); +``` + +Requires: :: + `Str` must be a _string-like_ type; that is, one with a nested `value_type` type (`Ch`) and with a nested `traits_type` type. + `str.data()` must return `Ch const*`. `str.size()` must return `std::size_t`. + `Ch` must be a character type (one of `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t`). + +Effects: :: + Parses a `uuid` string representation from the characters in the range `[str.data(), str.data() + str.size())` and stores the result in `u`. + On error, throws `std::runtime_error`. + +NOTE: Unlike `from_chars`, this function does not allow extra input; if after a complete UUID is parsed, unconsumed characters remain, an exception is thrown.