Delete Tensor constructor that takes a pointer. Otherwise, say, std::make_unique<Tensor>(GetTensorSomewhereThatActuallyReturnsAPointer()) would construct boolean tensor without a compile time error.
PiperOrigin-RevId: 311778946 Change-Id: Ibdb69ff7c4a9697028ed30ac40ffb0797b4493f9
This commit is contained in:
parent
aa002d9a78
commit
28229ffdbf
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
|
||||||
#include "tensorflow/core/framework/allocator.h"
|
#include "tensorflow/core/framework/allocator.h"
|
||||||
#include "tensorflow/core/framework/tensor_shape.h"
|
#include "tensorflow/core/framework/tensor_shape.h"
|
||||||
|
@ -239,6 +240,12 @@ class Tensor {
|
||||||
/// are not valid.
|
/// are not valid.
|
||||||
Tensor(Tensor&& other);
|
Tensor(Tensor&& other);
|
||||||
|
|
||||||
|
// Explicitly delete constructor that take a pointer (except char*)
|
||||||
|
// so that the pointer doesn't get implicitly cast to bool.
|
||||||
|
template <typename T, typename std::enable_if<!std::is_same<T, char>::value,
|
||||||
|
T>::type* = nullptr>
|
||||||
|
explicit Tensor(T* t) = delete;
|
||||||
|
|
||||||
~Tensor();
|
~Tensor();
|
||||||
|
|
||||||
/// Returns the data type.
|
/// Returns the data type.
|
||||||
|
|
Loading…
Reference in New Issue