Skip to content

Commit

Permalink
CI-testing a fix for the "ambiguous conversion" issue.
Browse files Browse the repository at this point in the history
This change is known to fix the `tensorflow::tstring` issue reported under #3521 (comment)

TODO: Minimal reproducer for the `tensorflow::tstring` issue.
  • Loading branch information
rwgk committed Dec 3, 2021
1 parent f56dc86 commit add6628
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/pybind11/pytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1185,8 +1185,10 @@ class bytes : public object {
}

#ifdef PYBIND11_HAS_STRING_VIEW
// enable_if is needed to avoid "ambiguous conversion" errors (see PR #3521).
// NOLINTNEXTLINE(google-explicit-constructor)
bytes(std::string_view s) : bytes(s.data(), s.size()) { }
template <typename T, detail::enable_if_t<std::is_same<T, std::string_view>::value, int> = 0>
bytes(T s) : bytes(s.data(), s.size()) { }

// Obtain a string view that views the current `bytes` buffer value. Note that this is only
// valid so long as the `bytes` instance remains alive and so generally should not outlive the
Expand Down

0 comments on commit add6628

Please sign in to comment.