v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
ostream_operators.h
Go to the documentation of this file.
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// Slightly adapted for inclusion in V8.
6// Copyright 2025 the V8 project authors. All rights reserved.
7
8#ifndef V8_BASE_NUMERICS_OSTREAM_OPERATORS_H_
9#define V8_BASE_NUMERICS_OSTREAM_OPERATORS_H_
10
11#include <ostream>
12#include <type_traits>
13
14namespace v8::base {
15namespace internal {
16
17template <typename T>
18 requires std::is_arithmetic_v<T>
19class ClampedNumeric;
20template <typename T>
21 requires std::is_arithmetic_v<T>
22class StrictNumeric;
23
24// Overload the ostream output operator to make logging work nicely.
25template <typename T>
26std::ostream& operator<<(std::ostream& os, const StrictNumeric<T>& value) {
27 os << static_cast<T>(value);
28 return os;
29}
30
31// Overload the ostream output operator to make logging work nicely.
32template <typename T>
33std::ostream& operator<<(std::ostream& os, const ClampedNumeric<T>& value) {
34 os << static_cast<T>(value);
35 return os;
36}
37
38} // namespace internal
39} // namespace v8::base
40
41#endif // V8_BASE_NUMERICS_OSTREAM_OPERATORS_H_
std::ostream & operator<<(std::ostream &os, const StrictNumeric< T > &value)
StrictNumeric(T) -> StrictNumeric< T >
ClampedNumeric(T) -> ClampedNumeric< T >