Fix PrepareForStrCat() for types that are AlphaNum constructible but not implicitly convertible.
In the latest dev version of Eigen, `Eigen::half` is implicitly convertible to float. This makes `std::is_constructible<AlphaNum,Eigen::half>` true (using the float constructor), but since `Eigen::half` is not implicitly convertible to `AlphaNum` directly, this leads to the compile error: ``` ./third_party/tensorflow/core/platform/errors.h:107:1: error: no matching function for call to 'PrepareForStrCat' ... ./third_party/tensorflow/core/platform/errors.h:54:33: note: candidate function not viable: no known conversion from 'Eigen::half' to 'const strings::AlphaNum' for 1st argument inline const strings::AlphaNum& PrepareForStrCat(const strings::AlphaNum& a) { ^ ./third_party/tensorflow/core/platform/errors.h:49:1: note: candidate template ignored: requirement '!std::is_constructible_v<tensorflow::strings::AlphaNum, Eigen::half>' was not satisfied [with T = Eigen::half] PrepareForStrCat(const T& t) { ^ ``` The same error occurs for any type implicitly convertible to int/float/double/string/etc... To fix this, we need to change the condition to `!is_convertible<T, AlphaNum>`, so that if `T` *is* implicitly convertible to `AlphaNum`, it will use the `AlphaNum` version, otherwise it will use the stream operator version. See [MR !278](https://gitlab.com/libeigen/eigen/-/merge_requests/278). PiperOrigin-RevId: 343357980 Change-Id: Ibad29a54105a70c473ca4c9b205fce8356d155ab
This commit is contained in:
parent
ad792f5eaf
commit
21f5c12e3d
@ -44,7 +44,7 @@ namespace internal {
|
||||
// Eventually absl::strings will have native support for this and we will be
|
||||
// able to completely remove PrepareForStrCat().
|
||||
template <typename T>
|
||||
typename std::enable_if<!std::is_constructible<strings::AlphaNum, T>::value,
|
||||
typename std::enable_if<!std::is_convertible<T, strings::AlphaNum>::value,
|
||||
std::string>::type
|
||||
PrepareForStrCat(const T& t) {
|
||||
std::stringstream ss;
|
||||
|
Loading…
Reference in New Issue
Block a user