nil instead of is_nil

This commit is contained in:
Marius Bancila 2017-12-18 14:23:52 +02:00
parent af28f41a14
commit 989e5dd661
6 changed files with 29 additions and 19 deletions

View File

@ -25,13 +25,13 @@ The following is a list of examples for using the library:
* Creating a nil UUID
```
uuid empty;
assert(empty.is_nil());
assert(empty.nil());
assert(empty.size() == 16);
```
* Creating a new UUID
```
uuid const guid = uuids::make_uuid();
assert(!guid.is_nil());
assert(!guid.nil());
assert(guid.size() == 16);
assert(guid.version() == uuids::uuid_version::random_number_based);
assert(guid.variant() == uuids::uuid_variant::rfc);
@ -64,18 +64,18 @@ assert(empty != guid);
uuid empty;
uuid guid = uuids::make_uuid();
assert(empty.is_nil());
assert(!guid.is_nil());
assert(empty.nil());
assert(!guid.nil());
std::swap(empty, guid);
assert(!empty.is_nil());
assert(guid.is_nil());
assert(!empty.nil());
assert(guid.nil());
empty.swap(guid);
assert(empty.is_nil());
assert(!guid.is_nil());
assert(empty.nil());
assert(!guid.nil());
```
* Converting to string
```

6
build/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
#ignore all
/*
# keep these files
!.gitignore
!readme.txt

5
build/readme.txt Normal file
View File

@ -0,0 +1,5 @@
Create a project from this folder by running the command:
cmake ..
If you don't have CMake installed you can get it from https://cmake.org/

View File

@ -120,7 +120,7 @@ namespace uuids
constexpr std::size_t size() const noexcept { return 16; }
constexpr bool is_nil() const noexcept
constexpr bool nil() const noexcept
{
for (size_t i = 0; i < data.size(); ++i) if (data[i] != 0) return false;
return true;

1
test/.gitignore vendored
View File

@ -1 +0,0 @@
CMakeFiles

View File

@ -12,7 +12,7 @@ int main()
std::cout << "Test default constructor" << std::endl;
uuid empty;
assert(empty.is_nil());
assert(empty.nil());
assert(empty.size() == 16);
}
@ -40,7 +40,7 @@ int main()
std::cout << "Test make" << std::endl;
uuid const guid = uuids::make_uuid();
assert(!guid.is_nil());
assert(!guid.nil());
assert(guid.size() == 16);
assert(guid.version() == uuids::uuid_version::random_number_based);
assert(guid.variant() == uuids::uuid_variant::rfc);
@ -106,18 +106,18 @@ int main()
uuid empty;
uuid guid = uuids::make_uuid();
assert(empty.is_nil());
assert(!guid.is_nil());
assert(empty.nil());
assert(!guid.nil());
std::swap(empty, guid);
assert(!empty.is_nil());
assert(guid.is_nil());
assert(!empty.nil());
assert(guid.nil());
empty.swap(guid);
assert(empty.is_nil());
assert(!guid.is_nil());
assert(empty.nil());
assert(!guid.nil());
}
{
@ -132,7 +132,7 @@ int main()
std::cout << "Test constexpr" << std::endl;
constexpr uuid empty;
constexpr bool isnil = empty.is_nil();
constexpr bool isnil = empty.nil();
constexpr size_t size = empty.size();
constexpr uuid_variant variant = empty.variant();
constexpr uuid_version version = empty.version();