uuid_default_system -> uuid_system_generator

This commit is contained in:
Marius Bancila 2018-01-31 09:05:04 +02:00
parent ea43f4b9ba
commit 8761a7ed7e
2 changed files with 12 additions and 18 deletions

View File

@ -659,11 +659,6 @@ namespace uuids
data.swap(other.data); data.swap(other.data);
} }
friend void swap(uuid& lhs, uuid& rhs) noexcept
{
std::swap(lhs.data, rhs.data);
}
iterator begin() noexcept { return uuid_iterator(&data[0], 0); } iterator begin() noexcept { return uuid_iterator(&data[0], 0); }
const_iterator begin() const noexcept { return uuid_const_iterator(&data[0], 0); } const_iterator begin() const noexcept { return uuid_const_iterator(&data[0], 0); }
iterator end() noexcept { return uuid_iterator(&data[0], state_size); } iterator end() noexcept { return uuid_iterator(&data[0], state_size); }
@ -769,7 +764,12 @@ namespace uuids
return sstr.str(); return sstr.str();
} }
class uuid_default_generator inline void swap(uuids::uuid & lhs, uuids::uuid & rhs)
{
lhs.swap(rhs);
}
class uuid_system_generator
{ {
public: public:
typedef uuid result_type; typedef uuid result_type;
@ -981,12 +981,6 @@ namespace uuids
namespace std namespace std
{ {
template <>
void swap(uuids::uuid & lhs, uuids::uuid & rhs)
{
lhs.swap(rhs);
}
template <> template <>
struct hash<uuids::uuid> struct hash<uuids::uuid>
{ {

View File

@ -80,7 +80,7 @@ int main()
std::cout << "Test equality" << std::endl; std::cout << "Test equality" << std::endl;
uuid empty; uuid empty;
uuid guid = uuids::uuid_default_generator{}(); uuid guid = uuids::uuid_random_generator{}();
assert(empty == empty); assert(empty == empty);
assert(guid == guid); assert(guid == guid);
@ -91,7 +91,7 @@ int main()
std::cout << "Test comparison" << std::endl; std::cout << "Test comparison" << std::endl;
auto empty = uuid{}; auto empty = uuid{};
uuids::uuid_default_generator gen; uuids::uuid_random_generator gen;
auto id = gen(); auto id = gen();
assert(empty < id); assert(empty < id);
@ -119,7 +119,7 @@ int main()
auto h2 = std::hash<uuid>{}; auto h2 = std::hash<uuid>{};
assert(h1(str) == h2(guid)); assert(h1(str) == h2(guid));
uuids::uuid_default_generator gen; uuids::uuid_random_generator gen;
std::unordered_set<uuids::uuid> ids{ std::unordered_set<uuids::uuid> ids{
uuid{}, uuid{},
@ -137,7 +137,7 @@ int main()
std::cout << "Test swap" << std::endl; std::cout << "Test swap" << std::endl;
uuid empty; uuid empty;
uuid guid = uuids::uuid_default_generator{}(); uuid guid = uuids::uuid_random_generator{}();
assert(empty.nil()); assert(empty.nil());
assert(!guid.nil()); assert(!guid.nil());
@ -213,7 +213,7 @@ int main()
{ {
std::cout << "Test default generator" << std::endl; std::cout << "Test default generator" << std::endl;
uuid const guid = uuids::uuid_default_generator{}(); uuid const guid = uuids::uuid_random_generator{}();
assert(!guid.nil()); assert(!guid.nil());
assert(guid.size() == 16); assert(guid.size() == 16);
assert(guid.version() == uuids::uuid_version::random_number_based); assert(guid.version() == uuids::uuid_version::random_number_based);
@ -402,7 +402,7 @@ int main()
{ {
std::cout << "Test name generator" << std::endl; std::cout << "Test name generator" << std::endl;
uuids::uuid_name_generator dgen(uuids::uuid_default_generator{}()); uuids::uuid_name_generator dgen(uuids::uuid{"47183823-2574-4bfd-b411-99ed177d3e43"});
auto id1 = dgen("john"); auto id1 = dgen("john");
assert(!id1.nil()); assert(!id1.nil());
assert(id1.size() == 16); assert(id1.size() == 16);