File tree Expand file tree Collapse file tree
src/rdf4cpp/storage/identifier Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ struct alignas(uint64_t) NodeBackendID {
3131 };
3232
3333public:
34- NodeBackendID () noexcept = default ;
34+ constexpr NodeBackendID () noexcept = default ;
3535
3636 explicit constexpr NodeBackendID (underlying_type const underlying_id) noexcept : underlying_{underlying_id} {
3737 }
@@ -138,8 +138,9 @@ struct alignas(uint64_t) NodeBackendID {
138138 return underlying_;
139139 }
140140
141- explicit constexpr operator underlying_type () const noexcept {
142- return underlying_;
141+ template <std::unsigned_integral I> requires (sizeof (I) >= sizeof (underlying_type))
142+ explicit constexpr operator I () const noexcept {
143+ return static_cast <I>(underlying_);
143144 }
144145
145146 constexpr std::strong_ordering operator <=>(NodeBackendID const &other) const noexcept {
@@ -153,6 +154,9 @@ struct alignas(uint64_t) NodeBackendID {
153154
154155static_assert (sizeof (NodeBackendID) == sizeof (uint64_t ));
155156static_assert (alignof (NodeBackendID) == alignof (uint64_t ));
157+ static_assert (std::is_same_v<decltype (static_cast <uintptr_t >(NodeBackendID{})), uintptr_t >, " NodeBackendID must be convertible to uintptr_t" );
158+ static_assert (std::is_same_v<decltype (static_cast <uint64_t >(NodeBackendID{})), uint64_t >, " NodeBackendID must be convertible to uint64_t" );
159+
156160
157161inline std::ostream &operator <<(std::ostream &os, NodeBackendID id) {
158162 if (id.is_literal ()) {
You can’t perform that action at this time.
0 commit comments