1 /* Copyright 2021 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 #ifndef TENSORFLOW_CC_EXPERIMENTAL_LIBTF_IMPL_NONE_H_ 16 #define TENSORFLOW_CC_EXPERIMENTAL_LIBTF_IMPL_NONE_H_ 17 18 #include <iosfwd> 19 #include <utility> 20 21 namespace tf { 22 namespace libtf { 23 namespace impl { 24 /// @brief The Singleton `None` class. 25 /// 26 /// This class is not user-constructible. To create a `None` instance, use 27 /// None::GetInstance(). 28 29 class None final { 30 public: 31 /// Retrieves the `None` instance. 32 /// 33 /// @return Returns the `None` singleton. 34 static None& GetInstance(); 35 36 /// Equality operator. 37 bool operator==(const None& other) const { return true; } 38 39 /// Overload AbslHashValue. 40 template <typename H> AbslHashValue(H h,const None & n)41 friend H AbslHashValue(H h, const None& n) { 42 return H::combine(std::move(h), 34559); 43 } 44 45 private: 46 // Private contructor. None()47 None() {} 48 }; 49 50 // Defined in iostream.cc. 51 std::ostream& operator<<(std::ostream& o, const None& none); 52 53 } // namespace impl 54 } // namespace libtf 55 } // namespace tf 56 57 #endif // TENSORFLOW_CC_EXPERIMENTAL_LIBTF_IMPL_NONE_H_ 58