Skip to content

Commit 66a4ade

Browse files
Merge pull request #56 from sketchylizard/FixTemplateParameters
Forward declare to_string function
2 parents 1da3294 + c4728ee commit 66a4ade

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

include/uuid.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ namespace uuids
352352
name_based_sha1 = 5 // The name-based version specified in RFS 4122 with SHA1 hashing
353353
};
354354

355+
// Forward declare uuid & to_string so that we can declare to_string as a friend later.
356+
class uuid;
357+
template <class CharT = char,
358+
class Traits = std::char_traits<CharT>,
359+
class Allocator = std::allocator<CharT>>
360+
std::basic_string<CharT, Traits, Allocator> to_string(uuid const &id);
361+
355362
// --------------------------------------------------------------------------------------------------------------------------
356363
// uuid class
357364
// --------------------------------------------------------------------------------------------------------------------------
@@ -550,9 +557,9 @@ namespace uuids
550557
return lhs.data < rhs.data;
551558
}
552559

553-
template<class CharT = char,
554-
class Traits = std::char_traits<CharT>,
555-
class Allocator = std::allocator<CharT>>
560+
template <class CharT,
561+
class Traits,
562+
class Allocator>
556563
inline std::basic_string<CharT, Traits, Allocator> to_string(uuid const & id)
557564
{
558565
std::basic_string<CharT, Traits, Allocator> uustr{detail::empty_guid<CharT>};
@@ -920,7 +927,7 @@ namespace std
920927
static_cast<uint64_t>(uuid.data[14]) << 8 |
921928
static_cast<uint64_t>(uuid.data[15]);
922929

923-
if (sizeof(result_type) > 4)
930+
if constexpr (sizeof(result_type) > 4)
924931
{
925932
return result_type(l ^ h);
926933
}

0 commit comments

Comments
 (0)