diff --git a/doc/uuid/uuid_io.adoc b/doc/uuid/uuid_io.adoc index 20cf40a..f4d46d7 100644 --- a/doc/uuid/uuid_io.adoc +++ b/doc/uuid/uuid_io.adoc @@ -30,6 +30,9 @@ template template bool to_chars( uuid const& u, Ch* first, Ch* last ) noexcept; +template + Ch* to_chars( uuid const& u, Ch (&buffer)[ N ] ) noexcept; + // to_string std::string to_string( uuid const& u ); @@ -151,6 +154,36 @@ assert( ret ); std::cout << std::string( buf, 36 ) << std::endl; ``` +``` +template + Ch* to_chars( uuid const& u, Ch (&buffer)[ N ] ) noexcept; +``` + +Requires: :: `Ch` must be a character type (one of `char`, `wchar_t`, `char8_t`, `char16_t`, `char32_t`); `N` must be at least 37. + +Effects: :: Writes the string representation of `u` (exactly 37 characters, including the null terminator) into `buffer`. + +Returns: :: `buffer + 36`. + +Example: :: ++ +``` +using namespace boost::uuids; + +uuid u = random_generator()(); + +char buf[ 37 ]; + +to_chars( u, buf ); + +std::cout << buf << std::endl; +``` + +NOTE: As a special exception, `N` is allowed to be 36 when `Ch` is `char`. + In this case, the function writes exactly 36 characters into `buffer` and does not write a null terminator. + This use is only supported for backward compatibility and is deprecated. + Use a buffer of 37 characters instead, to allow for the null terminator. + === to_string The functions `to_string` and `to_wstring` are provided as a convenience to convert a `uuid` to a string.