Skip to content

Commit 9bdfee1

Browse files
committed
api(ustringhash): make a public explicit ustringhash ctr from hash value (AcademySoftwareFoundation#3778)
1 parent c2ff5c2 commit 9bdfee1

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
@@ -837,6 +837,13 @@ class OIIO_UTIL_API ustringhash {
837837
#endif
838838
}
839839

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

@@ -965,7 +972,7 @@ class OIIO_UTIL_API ustringhash {
965972
#endif
966973

967974
/// Return the ustringhash corresponding to the given hash. Caveat emptor:
968-
/// results are undefined if it's not the valud hash of a ustring.
975+
/// results are undefined if it's not the valid hash of a ustring.
969976
OIIO_NODISCARD static constexpr ustringhash from_hash(hash_t hash)
970977
{
971978
ustringhash u;
@@ -977,13 +984,6 @@ class OIIO_UTIL_API ustringhash {
977984
// Individual ustringhash internal representation -- the hash value.
978985
rep_t m_hash;
979986

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

0 commit comments

Comments
 (0)