mirror of
https://github.com/boostorg/uuid.git
synced 2026-01-19 04:42:16 +00:00
Add charN_t support to to_chars
This commit is contained in:
@@ -22,6 +22,25 @@ constexpr wchar_t const* digits( wchar_t const* ) noexcept
|
||||
return L"0123456789abcdef-";
|
||||
}
|
||||
|
||||
constexpr char16_t const* digits( char16_t const* ) noexcept
|
||||
{
|
||||
return u"0123456789abcdef-";
|
||||
}
|
||||
|
||||
constexpr char32_t const* digits( char32_t const* ) noexcept
|
||||
{
|
||||
return U"0123456789abcdef-";
|
||||
}
|
||||
|
||||
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
|
||||
|
||||
constexpr char8_t const* digits( char8_t const* ) noexcept
|
||||
{
|
||||
return u8"0123456789abcdef-";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class Ch> inline Ch* to_chars( uuid const& u, Ch* out ) noexcept
|
||||
{
|
||||
constexpr Ch const* p = digits( static_cast<Ch const*>( nullptr ) );
|
||||
|
||||
@@ -33,18 +33,8 @@ OutputIterator to_chars( uuid const& u, OutputIterator out )
|
||||
return std::copy_n( tmp, 36, out );
|
||||
}
|
||||
|
||||
inline bool to_chars( uuid const& u, char* first, char* last ) noexcept
|
||||
{
|
||||
if( last - first < 36 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
detail::to_chars( u, first );
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool to_chars( uuid const& u, wchar_t* first, wchar_t* last ) noexcept
|
||||
template<class Ch>
|
||||
inline bool to_chars( uuid const& u, Ch* first, Ch* last ) noexcept
|
||||
{
|
||||
if( last - first < 36 )
|
||||
{
|
||||
|
||||
@@ -59,5 +59,17 @@ int main()
|
||||
test( u2, L"00010203-0405-0607-0809-0a0b0c0d0e0f" );
|
||||
test( u3, L"12345678-90ab-cdef-1234-567890abcdef" );
|
||||
|
||||
test( u1, u"00000000-0000-0000-0000-000000000000" );
|
||||
test( u2, u"00010203-0405-0607-0809-0a0b0c0d0e0f" );
|
||||
test( u3, u"12345678-90ab-cdef-1234-567890abcdef" );
|
||||
|
||||
test( u1, U"00000000-0000-0000-0000-000000000000" );
|
||||
test( u2, U"00010203-0405-0607-0809-0a0b0c0d0e0f" );
|
||||
test( u3, U"12345678-90ab-cdef-1234-567890abcdef" );
|
||||
|
||||
test( u1, u8"00000000-0000-0000-0000-000000000000" );
|
||||
test( u2, u8"00010203-0405-0607-0809-0a0b0c0d0e0f" );
|
||||
test( u3, u8"12345678-90ab-cdef-1234-567890abcdef" );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user