Merge branch 'faster-uuid-gen' into stable #1887

This commit is contained in:
Christopher Lam 2024-03-17 17:21:38 +08:00
commit 9cc31f329c
2 changed files with 9 additions and 4 deletions

View File

@ -331,8 +331,10 @@ GUID::to_string () const noexcept
}
GUID
GUID::from_string (std::string const & str)
GUID::from_string (const char* str)
{
if (!str)
throw guid_syntax_exception {};
try
{
static boost::uuids::string_generator strgen;
@ -345,7 +347,7 @@ GUID::from_string (std::string const & str)
}
bool
GUID::is_valid_guid (std::string const & str)
GUID::is_valid_guid (const char* str)
{
try
{

View File

@ -24,6 +24,7 @@
#include <boost/uuid/uuid.hpp>
#include <stdexcept>
#include <string>
#include "guid.h"
@ -48,8 +49,10 @@ struct GUID
operator GncGUID () const noexcept;
static GUID create_random () noexcept;
static GUID const & null_guid () noexcept;
static GUID from_string (std::string const &);
static bool is_valid_guid (std::string const &);
static GUID from_string (const char*);
static GUID from_string (std::string const& s) { return from_string (s.c_str()); };
static bool is_valid_guid (const char*);
static bool is_valid_guid (std::string const &s) { return is_valid_guid (s.c_str()); };
std::string to_string () const noexcept;
auto begin () const noexcept -> decltype (implementation.begin ());
auto end () const noexcept -> decltype (implementation.end ());