diff --git a/doc/uuid/examples.adoc b/doc/uuid/examples.adoc index 772cd4f..2383e9f 100644 --- a/doc/uuid/examples.adoc +++ b/doc/uuid/examples.adoc @@ -59,70 +59,6 @@ assert(o1 != o3); assert(o2 != o3); ---- -== POD Efficiencies - -This library implements a UUID as a POD allowing a UUID to be used in the most efficient ways, including using `memcpy`, and aggregate initializers. -A drawback is that a POD can not have any constructors, and thus declaring a UUID will not initialize it to a value generated by one of the defined mechanisms. -But a class based on a UUID can be defined that does initialize itself to a value generated by one of the defined mechanisms. - -[source,c++] ----- -// example using memcpy and aggregate initializers -// example of a class uuid see boost/libs/uuid/test/test_uuid_class.cpp - -#include -#include -#include - -{ // example using memcpy - unsigned char uuid_data[16]; - // fill uuid_data - - boost::uuids::uuid u; - - std::memcpy(&u.data, uuid_data, 16); -} - -{ // example using aggregate initializers - boost::uuids::uuid u = - {{ 0x12 ,0x34, 0x56, 0x78 - , 0x90, 0xab - , 0xcd, 0xef - , 0x12, 0x34 - , 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef - }}; -} - -// example of creating a uuid class that -// initializes the uuid in the constructor -// using a defined mechanism - -class uuid_class : public boost::uuids::uuid -{ -public: - uuid_class() - : boost::uuids::uuid(boost::uuids::random_generator()()) - {} - - explicit uuid_class(boost::uuids::uuid const& u) - : boost::uuids::uuid(u) - {} - - operator boost::uuids::uuid() { - return static_cast(*this); - } - - operator boost::uuids::uuid() const { - return static_cast(*this); - } -}; - -uuid_class u1; -uuid_class u2; - -assert(u1 != u2); ----- - == Byte Extraction It is sometimes useful to get at the 16 bytes of a `uuid` directly. Typical use is as follows: