Skip to content

Commit 3954b09

Browse files
committed
api(ustringhash): make a public explicit ustringhash ctr from hash value (#3778)
1 parent e191d3b commit 3954b09

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/include/OpenImageIO/ustring.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,13 @@ class OIIO_UTIL_API ustringhash {
835835
#endif
836836
}
837837

838+
/// Construct from a raw hash value. Beware: results are undefined if it's
839+
/// not the valid hash of a ustring.
840+
OIIO_HOSTDEVICE explicit constexpr ustringhash(size_t hash) noexcept
841+
: m_hash(hash)
842+
{
843+
}
844+
838845
/// Conversion to an OIIO::string_view.
839846
operator string_view() const noexcept { return ustring::from_hash(m_hash); }
840847

@@ -963,7 +970,7 @@ class OIIO_UTIL_API ustringhash {
963970
#endif
964971

965972
/// Return the ustringhash corresponding to the given hash. Caveat emptor:
966-
/// results are undefined if it's not the valud hash of a ustring.
973+
/// results are undefined if it's not the hash value of a ustring.
967974
OIIO_NODISCARD static constexpr ustringhash from_hash(size_t hash)
968975
{
969976
ustringhash u;
@@ -975,13 +982,6 @@ class OIIO_UTIL_API ustringhash {
975982
// Individual ustringhash internal representation -- the hash value.
976983
rep_t m_hash;
977984

978-
// Construct from a raw hash value. It's protected so that it's only
979-
// callable by its friend, ustring.
980-
OIIO_HOSTDEVICE ustringhash(size_t hashval)
981-
: m_hash(hashval)
982-
{
983-
}
984-
985985
friend class ustring;
986986
};
987987

0 commit comments

Comments
 (0)