Merge pull request #56 from sketchylizard/FixTemplateParameters

Forward declare to_string function
This commit is contained in:
Marius Bancila 2022-01-14 08:40:12 +02:00 committed by GitHub
commit 66a4adec66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -352,6 +352,13 @@ namespace uuids
name_based_sha1 = 5 // The name-based version specified in RFS 4122 with SHA1 hashing name_based_sha1 = 5 // The name-based version specified in RFS 4122 with SHA1 hashing
}; };
// Forward declare uuid & to_string so that we can declare to_string as a friend later.
class uuid;
template <class CharT = char,
class Traits = std::char_traits<CharT>,
class Allocator = std::allocator<CharT>>
std::basic_string<CharT, Traits, Allocator> to_string(uuid const &id);
// -------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------
// uuid class // uuid class
// -------------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------------
@ -550,9 +557,9 @@ namespace uuids
return lhs.data < rhs.data; return lhs.data < rhs.data;
} }
template<class CharT = char, template <class CharT,
class Traits = std::char_traits<CharT>, class Traits,
class Allocator = std::allocator<CharT>> class Allocator>
inline std::basic_string<CharT, Traits, Allocator> to_string(uuid const & id) inline std::basic_string<CharT, Traits, Allocator> to_string(uuid const & id)
{ {
std::basic_string<CharT, Traits, Allocator> uustr{detail::empty_guid<CharT>}; std::basic_string<CharT, Traits, Allocator> uustr{detail::empty_guid<CharT>};
@ -920,7 +927,7 @@ namespace std
static_cast<uint64_t>(uuid.data[14]) << 8 | static_cast<uint64_t>(uuid.data[14]) << 8 |
static_cast<uint64_t>(uuid.data[15]); static_cast<uint64_t>(uuid.data[15]);
if (sizeof(result_type) > 4) if constexpr (sizeof(result_type) > 4)
{ {
return result_type(l ^ h); return result_type(l ^ h);
} }