From c4728ee83b8d37f0579c13c6b49f6f108cdf1978 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 13 Jan 2022 13:52:16 -0800 Subject: [PATCH] Forward declare to_string function Forward declare to_string function before it is used in a friend declaration and deleted the default template parameters from the definition to prevent warnings in GCC. Also add "if constexp" to an if statement that was constant. --- include/uuid.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/uuid.h b/include/uuid.h index 07a46b8..63c54aa 100644 --- a/include/uuid.h +++ b/include/uuid.h @@ -352,6 +352,13 @@ namespace uuids 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 Allocator = std::allocator> + std::basic_string to_string(uuid const &id); + // -------------------------------------------------------------------------------------------------------------------------- // uuid class // -------------------------------------------------------------------------------------------------------------------------- @@ -550,9 +557,9 @@ namespace uuids return lhs.data < rhs.data; } - template, - class Allocator = std::allocator> + template inline std::basic_string to_string(uuid const & id) { std::basic_string uustr{detail::empty_guid}; @@ -920,7 +927,7 @@ namespace std static_cast(uuid.data[14]) << 8 | static_cast(uuid.data[15]); - if (sizeof(result_type) > 4) + if constexpr (sizeof(result_type) > 4) { return result_type(l ^ h); }