1 /* Copyright 2019 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 #ifndef TENSORFLOW_PYTHON_LIB_CORE_PYBIND11_ABSL_H_ 17 #define TENSORFLOW_PYTHON_LIB_CORE_PYBIND11_ABSL_H_ 18 19 #include "pybind11/pybind11.h" 20 #include "tensorflow/core/platform/stringpiece.h" 21 22 #ifndef ABSL_USES_STD_STRING_VIEW 23 24 namespace pybind11 { 25 namespace detail { 26 27 // Convert between tensorflow::StringPiece (aka absl::string_view) and Python. 28 // 29 // pybind11 supports std::string_view, and absl::string_view is meant to be a 30 // drop-in replacement for std::string_view, so we can just use the built in 31 // implementation. 32 template <> 33 struct type_caster<tensorflow::StringPiece> 34 : string_caster<tensorflow::StringPiece, true> {}; 35 36 } // namespace detail 37 } // namespace pybind11 38 39 #endif // ABSL_USES_STD_STRING_VIEW 40 #endif // TENSORFLOW_PYTHON_LIB_CORE_PYBIND11_ABSL_H_ 41