boostorg / uuid

Boost.org uuid module
http://boost.org/libs/uuid
Boost Software License 1.0
81 stars 67 forks source link

uuid no longer constexpr contructable #161

Open tobias-loew opened 1 month ago

tobias-loew commented 1 month ago

Before version 1.85 uuid was an aggreagate and could be constexpr constructed from a sequence of bytes. With version 1.85 this is no longer possible. (I've got user-defined literal which converts uuid string-representation at compile-time into uuids that no longer works with 1.85.)

pdimov commented 1 month ago

Indeed, thanks for the report. I'll see if I can fix this between the beta and the release, as it's not as easy as just adding a constexpr to the constructor because std::memcpy isn't always constexpr.

tobias-loew commented 1 month ago

Another minor regression: before .data returned a reference to the array. Migration would be easier having a data() method returning a reference or a std::span to the byte representation.

pdimov commented 1 month ago

For a contiguous container, data() by convention returns a pointer to the first element. It's in principle possible to return a reference to the array which will decay to a pointer but that's a bit too inventive.

Although maybe if the constructor is constexpr, data() should be, too.

Osyotr commented 2 weeks ago

It's also no longer trivial: https://godbolt.org/z/sb8K6YTz7 Probably because of this line: https://github.com/boostorg/uuid/blob/c432e16a4c6b477a1f1e0bbdc6de806237b0c4f0/include/boost/uuid/uuid.hpp#L96

pdimov commented 2 weeks ago

It's still trivially copyable and standard layout, but no longer trivial (because the default constructor doesn't leave it uninitialized) or POD.