Skip to content

Commit 916f673

Browse files
committed
Make linter happy; comment reinterpret_cast safety
1 parent cc144df commit 916f673

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/pybind11/pytypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,7 @@ class str : public object {
10901090
str(std::string_view s) : str(s.data(), s.size()) { }
10911091

10921092
# ifdef PYBIND11_HAS_U8STRING
1093+
// reinterpret_cast here is safe (C++20 guarantees char8_t has the same size/alignment as char)
10931094
// NOLINTNEXTLINE(google-explicit-constructor)
10941095
str(std::u8string_view s) : str(reinterpret_cast<const char*>(s.data()), s.size()) { }
10951096
# endif
@@ -1186,6 +1187,7 @@ class bytes : public object {
11861187
// Obtain a string view that views the current `bytes` buffer value. Note that this is only
11871188
// valid so long as the `bytes` instance remains alive and so generally should not outlive the
11881189
// lifetime of the `bytes` instance.
1190+
// NOLINTNEXTLINE(google-explicit-constructor)
11891191
operator std::string_view() const {
11901192
char *buffer = nullptr;
11911193
ssize_t length = 0;

0 commit comments

Comments
 (0)