Skip to content

C++20 constexpr guid parser and consteval guid literal.

License

Notifications You must be signed in to change notification settings

bogu9821/GuidParserConstexpr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GuidParserConstexpr

Example

#include "GuidParser.hpp"

#include <algorithm>    //std::ranges::equal
#include <array>        //std::array
#include <iostream>     //std::cout

using namespace GuidParser::GuidLiteral;

static constexpr GUID guid = "{20f892f5-b841-4c46-8547-7d2e7687a30a}"_guid;

int main()
{
	static constexpr std::array<std::uint8_t, 8> MyData4 = { 133, 71, 125, 46, 118, 135, 163, 10 };
	static_assert(guid.Data1 == 553161461 && guid.Data2 == 47169
		&& guid.Data3 == 19526 && std::ranges::equal(MyData4, guid.Data4));

	static constexpr auto stringGuid = GuidParser::GuidToString(guid);
	
	std::cout << "static_assert for " << stringGuid.data() << " passed\n";

	std::optional<GUID> optionalGuid = GuidParser::StringToGuid("{474ccf9f-bad7-48e2-b7c6-df307b74e4a5}");

	if (optionalGuid.has_value())
	{
		return 0;
	}

	return -1;
}

About

C++20 constexpr guid parser and consteval guid literal.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages