v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
safe_conversions.h File Reference
#include <stddef.h>
#include <cmath>
#include <concepts>
#include <limits>
#include <type_traits>
#include "src/base/numerics/safe_conversions_impl.h"
Include dependency graph for safe_conversions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  v8::base::internal::SaturateFastAsmOp< Dst, Src >
 
struct  v8::base::internal::IsValueInRangeFastOp< Dst, Src >
 
struct  v8::base::internal::IsValueInRangeFastOp< Dst, Src >
 
struct  v8::base::internal::SaturationDefaultLimits< T >
 
struct  v8::base::internal::SaturateFastOp< Dst, Src >
 
struct  v8::base::internal::SaturateFastOp< Dst, Src >
 
class  v8::base::internal::StrictNumeric< T >
 

Namespaces

namespace  v8
 
namespace  v8::base
 
namespace  v8::base::internal
 

Macros

#define BASE_HAS_OPTIMIZED_SAFE_CONVERSIONS   (0)
 
#define BASE_NUMERIC_COMPARISON_OPERATORS(CLASS, NAME, OP)
 

Typedefs

using v8::base::SizeT = StrictNumeric<size_t>
 

Functions

template<typename Dst , typename Src >
requires (IsNumeric<Src> && std::is_arithmetic_v<Dst> && std::numeric_limits<Dst>::lowest() < std::numeric_limits<Dst>::max())
constexpr bool v8::base::internal::IsValueInRangeForNumericType (Src value)
 
template<typename Dst , class CheckHandler = internal::CheckOnFailure, typename Src >
requires (IsNumeric<Src> && std::is_arithmetic_v<Dst> && std::numeric_limits<Dst>::lowest() < std::numeric_limits<Dst>::max())
constexpr Dst v8::base::internal::checked_cast (Src value)
 
template<typename Dst , template< typename > class S, typename Src >
constexpr Dst v8::base::internal::saturated_cast_impl (Src value, RangeCheck constraint)
 
template<typename Dst , template< typename > class SaturationHandler = SaturationDefaultLimits, typename Src >
constexpr Dst v8::base::internal::saturated_cast (Src value)
 
template<typename Dst , typename Src , typename SrcType = UnderlyingType<Src>>
requires ( IsNumeric<Src> && std::is_arithmetic_v<Dst> && // If you got here from a compiler error, it's because you tried to assign // from a source type to a destination type that has insufficient range. // The solution may be to change the destination type you're assigning to, // and use one large enough to represent the source. // Alternatively, you may be better served with the checked_cast<> or // saturated_cast<> template functions for your particular use case. kStaticDstRangeRelationToSrcRange<Dst, SrcType> == NumericRangeRepresentation::kContained)
constexpr Dst v8::base::internal::strict_cast (Src value)
 
template<typename T >
 v8::base::internal::StrictNumeric (T) -> StrictNumeric< T >
 
template<typename T >
constexpr StrictNumeric< UnderlyingType< T > > v8::base::internal::MakeStrictNum (const T value)
 
template<typename Dst = int, typename Src >
requires (std::integral<Dst> && std::floating_point<Src>)
Dst v8::base::ClampFloor (Src value)
 
template<typename Dst = int, typename Src >
requires (std::integral<Dst> && std::floating_point<Src>)
Dst v8::base::ClampCeil (Src value)
 
template<typename Dst = int, typename Src >
requires (std::integral<Dst> && std::floating_point<Src>)
Dst v8::base::ClampRound (Src value)
 

Variables

template<typename Dst , typename Src >
constexpr bool v8::base::internal::kIsNumericRangeContained = false
 
template<typename Dst , typename Src >
constexpr bool v8::base::internal::kIsNumericRangeContained< Dst, Src >
 

Macro Definition Documentation

◆ BASE_HAS_OPTIMIZED_SAFE_CONVERSIONS

#define BASE_HAS_OPTIMIZED_SAFE_CONVERSIONS   (0)

Definition at line 24 of file safe_conversions.h.

◆ BASE_NUMERIC_COMPARISON_OPERATORS

#define BASE_NUMERIC_COMPARISON_OPERATORS ( CLASS,
NAME,
OP )
Value:
template <typename L, typename R> \
requires(internal::Is##CLASS##Op<L, R>) \
constexpr bool operator OP(L lhs, R rhs) { \
return SafeCompare<NAME, UnderlyingType<L>, UnderlyingType<R>>(lhs, rhs); \
}
#define OP(kType)

Definition at line 314 of file safe_conversions.h.