1 // Copyright 2021 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_NUMERICS_OSTREAM_OPERATORS_H_ 6 #define BASE_NUMERICS_OSTREAM_OPERATORS_H_ 7 8 #include <ostream> 9 10 namespace base { 11 namespace internal { 12 13 template <typename T> 14 class ClampedNumeric; 15 template <typename T> 16 class StrictNumeric; 17 18 // Overload the ostream output operator to make logging work nicely. 19 template <typename T> 20 std::ostream& operator<<(std::ostream& os, const StrictNumeric<T>& value) { 21 os << static_cast<T>(value); 22 return os; 23 } 24 25 // Overload the ostream output operator to make logging work nicely. 26 template <typename T> 27 std::ostream& operator<<(std::ostream& os, const ClampedNumeric<T>& value) { 28 os << static_cast<T>(value); 29 return os; 30 } 31 32 } // namespace internal 33 } // namespace base 34 35 #endif // BASE_NUMERICS_OSTREAM_OPERATORS_H_ 36