Commit c9abc311 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[base][cleanup] Using 'using' instead of 'typedef'

Even though both are allowed in the style guide, it recommends to use
'using', as its syntax is more consistent with the rest of C++.
This CL turns all typedefs in base code to 'using' declarations.

R=mlippautz@chromium.org

Bug: v8:8834
Change-Id: Ic5c3d7fa2e50938c6f43e9ff304dc2289fed1133
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1547650Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60546}
parent b1a91ce5
......@@ -15,7 +15,7 @@ namespace base {
// Helper class representing an address region of certain size.
class AddressRegion {
public:
typedef uintptr_t Address;
using Address = uintptr_t;
AddressRegion() = default;
......
......@@ -39,22 +39,22 @@
namespace v8 {
namespace base {
typedef char Atomic8;
typedef int16_t Atomic16;
typedef int32_t Atomic32;
using Atomic8 = char;
using Atomic16 = int16_t;
using Atomic32 = int32_t;
#if defined(V8_HOST_ARCH_64_BIT)
// We need to be able to go between Atomic64 and AtomicWord implicitly. This
// means Atomic64 and AtomicWord should be the same type on 64-bit.
#if defined(__ILP32__)
typedef int64_t Atomic64;
using Atomic64 = int64_t;
#else
typedef intptr_t Atomic64;
using Atomic64 = intptr_t;
#endif // defined(__ILP32__)
#endif // defined(V8_HOST_ARCH_64_BIT)
// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
// Atomic64 routines below, depending on your architecture.
typedef intptr_t AtomicWord;
using AtomicWord = intptr_t;
// Atomically execute:
// result = *ptr;
......
......@@ -25,7 +25,7 @@ namespace base {
// The implementation is thread-safe.
class V8_BASE_EXPORT BoundedPageAllocator : public v8::PageAllocator {
public:
typedef uintptr_t Address;
using Address = uintptr_t;
BoundedPageAllocator(v8::PageAllocator* page_allocator, Address start,
size_t size, size_t allocate_page_size);
......
......@@ -24,8 +24,8 @@ namespace base {
template <typename T, typename S = int>
class Flags final {
public:
typedef T flag_type;
typedef S mask_type;
using flag_type = T;
using mask_type = S;
constexpr Flags() : mask_(0) {}
constexpr Flags(flag_type flag) // NOLINT(runtime/explicit)
......
......@@ -27,7 +27,7 @@ class DefaultAllocationPolicy {
template <typename Key, typename Value, class MatchFun, class AllocationPolicy>
class TemplateHashMapImpl {
public:
typedef TemplateHashMapEntry<Key, Value> Entry;
using Entry = TemplateHashMapEntry<Key, Value>;
// The default capacity. This is used by the call sites which want
// to pass in a non-default AllocationPolicy but want to use the
......@@ -389,13 +389,12 @@ class CustomMatcherTemplateHashMapImpl
void*, void*,
HashEqualityThenKeyMatcher<void*, bool (*)(void*, void*)>,
AllocationPolicy> {
typedef TemplateHashMapImpl<
using Base = TemplateHashMapImpl<
void*, void*, HashEqualityThenKeyMatcher<void*, bool (*)(void*, void*)>,
AllocationPolicy>
Base;
AllocationPolicy>;
public:
typedef bool (*MatchFun)(void*, void*);
using MatchFun = bool (*)(void*, void*);
CustomMatcherTemplateHashMapImpl(
MatchFun match, uint32_t capacity = Base::kDefaultHashMapCapacity,
......@@ -412,8 +411,8 @@ class CustomMatcherTemplateHashMapImpl
DISALLOW_COPY_AND_ASSIGN(CustomMatcherTemplateHashMapImpl);
};
typedef CustomMatcherTemplateHashMapImpl<DefaultAllocationPolicy>
CustomMatcherHashMap;
using CustomMatcherHashMap =
CustomMatcherTemplateHashMapImpl<DefaultAllocationPolicy>;
// Match function which compares keys directly by equality.
template <typename Key>
......@@ -429,9 +428,8 @@ template <typename AllocationPolicy>
class PointerTemplateHashMapImpl
: public TemplateHashMapImpl<void*, void*, KeyEqualityMatcher<void*>,
AllocationPolicy> {
typedef TemplateHashMapImpl<void*, void*, KeyEqualityMatcher<void*>,
AllocationPolicy>
Base;
using Base = TemplateHashMapImpl<void*, void*, KeyEqualityMatcher<void*>,
AllocationPolicy>;
public:
PointerTemplateHashMapImpl(uint32_t capacity = Base::kDefaultHashMapCapacity,
......@@ -439,7 +437,7 @@ class PointerTemplateHashMapImpl
: Base(capacity, KeyEqualityMatcher<void*>(), allocator) {}
};
typedef PointerTemplateHashMapImpl<DefaultAllocationPolicy> HashMap;
using HashMap = PointerTemplateHashMapImpl<DefaultAllocationPolicy>;
// A hash map for pointer keys and values with an STL-like interface.
template <class Key, class Value, class MatchFun, class AllocationPolicy>
......@@ -447,10 +445,9 @@ class TemplateHashMap
: private TemplateHashMapImpl<void*, void*,
HashEqualityThenKeyMatcher<void*, MatchFun>,
AllocationPolicy> {
typedef TemplateHashMapImpl<void*, void*,
HashEqualityThenKeyMatcher<void*, MatchFun>,
AllocationPolicy>
Base;
using Base = TemplateHashMapImpl<void*, void*,
HashEqualityThenKeyMatcher<void*, MatchFun>,
AllocationPolicy>;
public:
STATIC_ASSERT(sizeof(Key*) == sizeof(void*)); // NOLINT
......
......@@ -57,7 +57,7 @@ namespace {
#if V8_TARGET_LITTLE_ENDIAN
typedef union {
union ieee_double_shape_type {
double value;
struct {
uint32_t lsw;
......@@ -66,11 +66,11 @@ typedef union {
struct {
uint64_t w;
} xparts;
} ieee_double_shape_type;
};
#else
typedef union {
union ieee_double_shape_type {
double value;
struct {
uint32_t msw;
......@@ -79,7 +79,7 @@ typedef union {
struct {
uint64_t w;
} xparts;
} ieee_double_shape_type;
};
#endif
......
......@@ -13,11 +13,11 @@ namespace base {
template <class Category, class Type, class Diff = std::ptrdiff_t,
class Pointer = Type*, class Reference = Type&>
struct iterator {
typedef Category iterator_category;
typedef Type value_type;
typedef Diff difference_type;
typedef Pointer pointer;
typedef Reference reference;
using iterator_category = Category;
using value_type = Type;
using difference_type = Diff;
using pointer = Pointer;
using reference = Reference;
};
// The intention of the base::iterator_range class is to encapsulate two
......@@ -27,13 +27,13 @@ struct iterator {
template <typename ForwardIterator>
class iterator_range {
public:
typedef ForwardIterator iterator;
typedef ForwardIterator const_iterator;
typedef typename std::iterator_traits<iterator>::pointer pointer;
typedef typename std::iterator_traits<iterator>::reference reference;
typedef typename std::iterator_traits<iterator>::value_type value_type;
typedef
typename std::iterator_traits<iterator>::difference_type difference_type;
using iterator = ForwardIterator;
using const_iterator = ForwardIterator;
using pointer = typename std::iterator_traits<iterator>::pointer;
using reference = typename std::iterator_traits<iterator>::reference;
using value_type = typename std::iterator_traits<iterator>::value_type;
using difference_type =
typename std::iterator_traits<iterator>::difference_type;
iterator_range() : begin_(), end_() {}
template <typename ForwardIterator1, typename ForwardIterator2>
......
......@@ -199,8 +199,8 @@ template <typename T,
typename InitOnceTrait = ThreadSafeInitOnceTrait,
typename DestroyTrait = LeakyInstanceTrait<T> >
struct LazyStaticInstance {
typedef LazyInstanceImpl<T, StaticallyAllocatedInstanceTrait<T>,
CreateTrait, InitOnceTrait, DestroyTrait> type;
using type = LazyInstanceImpl<T, StaticallyAllocatedInstanceTrait<T>,
CreateTrait, InitOnceTrait, DestroyTrait>;
};
......@@ -210,8 +210,8 @@ template <typename T,
typename DestroyTrait = LeakyInstanceTrait<T> >
struct LazyInstance {
// A LazyInstance is a LazyStaticInstance.
typedef typename LazyStaticInstance<T, CreateTrait, InitOnceTrait,
DestroyTrait>::type type;
using type = typename LazyStaticInstance<T, CreateTrait, InitOnceTrait,
DestroyTrait>::type;
};
......@@ -220,8 +220,8 @@ template <typename T,
typename InitOnceTrait = ThreadSafeInitOnceTrait,
typename DestroyTrait = LeakyInstanceTrait<T> >
struct LazyDynamicInstance {
typedef LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>,
CreateTrait, InitOnceTrait, DestroyTrait> type;
using type = LazyInstanceImpl<T, DynamicallyAllocatedInstanceTrait<T>,
CreateTrait, InitOnceTrait, DestroyTrait>;
};
// LeakyObject<T> wraps an object of type T, which is initialized in the
......
......@@ -74,11 +74,11 @@ enum : uint8_t {
ONCE_STATE_DONE = 2
};
typedef void (*PointerArgFunction)(void* arg);
using PointerArgFunction = void (*)(void* arg);
template <typename T>
struct OneArgFunction {
typedef void (*type)(T);
using type = void (*)(T);
};
V8_BASE_EXPORT void CallOnceImpl(OnceType* once,
......
......@@ -24,7 +24,7 @@ namespace base {
template <typename signed_type> \
inline signed_type Name##WithWraparound(signed_type a, signed_type b) { \
ASSERT_SIGNED_INTEGER_TYPE(signed_type); \
typedef typename std::make_unsigned<signed_type>::type unsigned_type; \
using unsigned_type = typename std::make_unsigned<signed_type>::type; \
unsigned_type a_unsigned = static_cast<unsigned_type>(a); \
unsigned_type b_unsigned = static_cast<unsigned_type>(b); \
unsigned_type result = a_unsigned OP b_unsigned; \
......@@ -57,7 +57,7 @@ inline signed_type NegateWithWraparound(signed_type a) {
template <typename signed_type>
inline signed_type ShlWithWraparound(signed_type a, signed_type b) {
ASSERT_SIGNED_INTEGER_TYPE(signed_type);
typedef typename std::make_unsigned<signed_type>::type unsigned_type;
using unsigned_type = typename std::make_unsigned<signed_type>::type;
const unsigned_type kMask = (sizeof(a) * 8) - 1;
return static_cast<signed_type>(static_cast<unsigned_type>(a) << (b & kMask));
}
......
......@@ -61,9 +61,9 @@ class V8_BASE_EXPORT ConditionVariable final {
// The implementation-defined native handle type.
#if V8_OS_POSIX
typedef pthread_cond_t NativeHandle;
using NativeHandle = pthread_cond_t;
#elif V8_OS_WIN
typedef CONDITION_VARIABLE NativeHandle;
using NativeHandle = CONDITION_VARIABLE;
#endif
NativeHandle& native_handle() {
......@@ -89,9 +89,10 @@ class V8_BASE_EXPORT ConditionVariable final {
// MutexGuard lock_guard(&my_mutex);
// my_condvar.Pointer()->Wait(&my_mutex);
// }
typedef LazyStaticInstance<
ConditionVariable, DefaultConstructTrait<ConditionVariable>,
ThreadSafeInitOnceTrait>::type LazyConditionVariable;
using LazyConditionVariable =
LazyStaticInstance<ConditionVariable,
DefaultConstructTrait<ConditionVariable>,
ThreadSafeInitOnceTrait>::type;
#define LAZY_CONDITION_VARIABLE_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER
......
......@@ -55,9 +55,9 @@ class V8_BASE_EXPORT Mutex final {
// The implementation-defined native handle type.
#if V8_OS_POSIX
typedef pthread_mutex_t NativeHandle;
using NativeHandle = pthread_mutex_t;
#elif V8_OS_WIN
typedef SRWLOCK NativeHandle;
using NativeHandle = SRWLOCK;
#endif
NativeHandle& native_handle() {
......@@ -101,8 +101,8 @@ class V8_BASE_EXPORT Mutex final {
// // Do something.
// }
//
typedef LazyStaticInstance<Mutex, DefaultConstructTrait<Mutex>,
ThreadSafeInitOnceTrait>::type LazyMutex;
using LazyMutex = LazyStaticInstance<Mutex, DefaultConstructTrait<Mutex>,
ThreadSafeInitOnceTrait>::type;
#define LAZY_MUTEX_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER
......@@ -153,9 +153,9 @@ class V8_BASE_EXPORT RecursiveMutex final {
private:
// The implementation-defined native handle type.
#if V8_OS_POSIX
typedef pthread_mutex_t NativeHandle;
using NativeHandle = pthread_mutex_t;
#elif V8_OS_WIN
typedef CRITICAL_SECTION NativeHandle;
using NativeHandle = CRITICAL_SECTION;
#endif
NativeHandle native_handle_;
......@@ -177,9 +177,9 @@ class V8_BASE_EXPORT RecursiveMutex final {
// // Do something.
// }
//
typedef LazyStaticInstance<RecursiveMutex,
DefaultConstructTrait<RecursiveMutex>,
ThreadSafeInitOnceTrait>::type LazyRecursiveMutex;
using LazyRecursiveMutex =
LazyStaticInstance<RecursiveMutex, DefaultConstructTrait<RecursiveMutex>,
ThreadSafeInitOnceTrait>::type;
#define LAZY_RECURSIVE_MUTEX_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER
......@@ -241,9 +241,9 @@ class V8_BASE_EXPORT SharedMutex final {
private:
// The implementation-defined native handle type.
#if V8_OS_POSIX
typedef pthread_rwlock_t NativeHandle;
using NativeHandle = pthread_rwlock_t;
#elif V8_OS_WIN
typedef SRWLOCK NativeHandle;
using NativeHandle = SRWLOCK;
#endif
NativeHandle native_handle_;
......
......@@ -1072,58 +1072,44 @@ Win32MemoryMappedFile::~Win32MemoryMappedFile() {
// DbgHelp isn't supported on MinGW yet
#ifndef __MINGW32__
// DbgHelp.h functions.
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymInitialize))(IN HANDLE hProcess,
IN PSTR UserSearchPath,
IN BOOL fInvadeProcess);
typedef DWORD (__stdcall *DLL_FUNC_TYPE(SymGetOptions))(VOID);
typedef DWORD (__stdcall *DLL_FUNC_TYPE(SymSetOptions))(IN DWORD SymOptions);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetSearchPath))(
IN HANDLE hProcess,
OUT PSTR SearchPath,
IN DWORD SearchPathLength);
typedef DWORD64 (__stdcall *DLL_FUNC_TYPE(SymLoadModule64))(
IN HANDLE hProcess,
IN HANDLE hFile,
IN PSTR ImageName,
IN PSTR ModuleName,
IN DWORD64 BaseOfDll,
IN DWORD SizeOfDll);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(StackWalk64))(
DWORD MachineType,
HANDLE hProcess,
HANDLE hThread,
LPSTACKFRAME64 StackFrame,
PVOID ContextRecord,
using DLL_FUNC_TYPE(SymInitialize) = BOOL(__stdcall*)(IN HANDLE hProcess,
IN PSTR UserSearchPath,
IN BOOL fInvadeProcess);
using DLL_FUNC_TYPE(SymGetOptions) = DWORD(__stdcall*)(VOID);
using DLL_FUNC_TYPE(SymSetOptions) = DWORD(__stdcall*)(IN DWORD SymOptions);
using DLL_FUNC_TYPE(SymGetSearchPath) = BOOL(__stdcall*)(
IN HANDLE hProcess, OUT PSTR SearchPath, IN DWORD SearchPathLength);
using DLL_FUNC_TYPE(SymLoadModule64) = DWORD64(__stdcall*)(
IN HANDLE hProcess, IN HANDLE hFile, IN PSTR ImageName, IN PSTR ModuleName,
IN DWORD64 BaseOfDll, IN DWORD SizeOfDll);
using DLL_FUNC_TYPE(StackWalk64) = BOOL(__stdcall*)(
DWORD MachineType, HANDLE hProcess, HANDLE hThread,
LPSTACKFRAME64 StackFrame, PVOID ContextRecord,
PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,
PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetSymFromAddr64))(
IN HANDLE hProcess,
IN DWORD64 qwAddr,
OUT PDWORD64 pdwDisplacement,
using DLL_FUNC_TYPE(SymGetSymFromAddr64) = BOOL(__stdcall*)(
IN HANDLE hProcess, IN DWORD64 qwAddr, OUT PDWORD64 pdwDisplacement,
OUT PIMAGEHLP_SYMBOL64 Symbol);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetLineFromAddr64))(
IN HANDLE hProcess,
IN DWORD64 qwAddr,
OUT PDWORD pdwDisplacement,
OUT PIMAGEHLP_LINE64 Line64);
using DLL_FUNC_TYPE(SymGetLineFromAddr64) =
BOOL(__stdcall*)(IN HANDLE hProcess, IN DWORD64 qwAddr,
OUT PDWORD pdwDisplacement, OUT PIMAGEHLP_LINE64 Line64);
// DbgHelp.h typedefs. Implementation found in dbghelp.dll.
typedef PVOID (__stdcall *DLL_FUNC_TYPE(SymFunctionTableAccess64))(
using DLL_FUNC_TYPE(SymFunctionTableAccess64) = PVOID(__stdcall*)(
HANDLE hProcess,
DWORD64 AddrBase); // DbgHelp.h typedef PFUNCTION_TABLE_ACCESS_ROUTINE64
typedef DWORD64 (__stdcall *DLL_FUNC_TYPE(SymGetModuleBase64))(
using DLL_FUNC_TYPE(SymGetModuleBase64) = DWORD64(__stdcall*)(
HANDLE hProcess,
DWORD64 AddrBase); // DbgHelp.h typedef PGET_MODULE_BASE_ROUTINE64
// TlHelp32.h functions.
typedef HANDLE (__stdcall *DLL_FUNC_TYPE(CreateToolhelp32Snapshot))(
DWORD dwFlags,
DWORD th32ProcessID);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(Module32FirstW))(HANDLE hSnapshot,
LPMODULEENTRY32W lpme);
typedef BOOL (__stdcall *DLL_FUNC_TYPE(Module32NextW))(HANDLE hSnapshot,
using DLL_FUNC_TYPE(CreateToolhelp32Snapshot) =
HANDLE(__stdcall*)(DWORD dwFlags, DWORD th32ProcessID);
using DLL_FUNC_TYPE(Module32FirstW) = BOOL(__stdcall*)(HANDLE hSnapshot,
LPMODULEENTRY32W lpme);
using DLL_FUNC_TYPE(Module32NextW) = BOOL(__stdcall*)(HANDLE hSnapshot,
LPMODULEENTRY32W lpme);
#undef IN
#undef VOID
......
......@@ -311,7 +311,7 @@ inline void EnsureConsoleOutput() {
class V8_BASE_EXPORT Thread {
public:
// Opaque data type for thread-local storage keys.
typedef int32_t LocalStorageKey;
using LocalStorageKey = int32_t;
class Options {
public:
......
......@@ -50,11 +50,11 @@ class V8_BASE_EXPORT Semaphore final {
bool WaitFor(const TimeDelta& rel_time) V8_WARN_UNUSED_RESULT;
#if V8_OS_MACOSX
typedef semaphore_t NativeHandle;
using NativeHandle = semaphore_t;
#elif V8_OS_POSIX
typedef sem_t NativeHandle;
using NativeHandle = sem_t;
#elif V8_OS_WIN
typedef HANDLE NativeHandle;
using NativeHandle = HANDLE;
#endif
NativeHandle& native_handle() {
......@@ -90,8 +90,8 @@ struct CreateSemaphoreTrait {
template <int N>
struct LazySemaphore {
typedef typename LazyDynamicInstance<Semaphore, CreateSemaphoreTrait<N>,
ThreadSafeInitOnceTrait>::type type;
using typename LazyDynamicInstance<Semaphore, CreateSemaphoreTrait<N>,
ThreadSafeInitOnceTrait>::type;
};
#define LAZY_SEMAPHORE_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER
......
......@@ -25,7 +25,7 @@ namespace base {
// Not thread-safe.
class V8_BASE_EXPORT RegionAllocator final {
public:
typedef uintptr_t Address;
using Address = uintptr_t;
static constexpr Address kAllocationFailure = static_cast<Address>(-1);
......@@ -121,7 +121,7 @@ class V8_BASE_EXPORT RegionAllocator final {
}
};
// All regions ordered by addresses.
typedef std::set<Region*, AddressEndOrder> AllRegionsSet;
using AllRegionsSet = std::set<Region*, AddressEndOrder>;
AllRegionsSet all_regions_;
struct SizeAddressOrder {
......
......@@ -47,7 +47,7 @@ namespace internal {
template <typename T>
class CheckedNumeric {
public:
typedef T type;
using type = T;
CheckedNumeric() = default;
......@@ -200,7 +200,7 @@ class CheckedNumeric {
template <typename T> \
CheckedNumeric<typename ArithmeticPromotion<T>::type> operator OP( \
const CheckedNumeric<T>& lhs, const CheckedNumeric<T>& rhs) { \
typedef typename ArithmeticPromotion<T>::type Promotion; \
using Promotion = typename ArithmeticPromotion<T>::type; \
/* Floating point always takes the fast path */ \
if (std::numeric_limits<T>::is_iec559) \
return CheckedNumeric<T>(lhs.ValueUnsafe() OP rhs.ValueUnsafe()); \
......@@ -209,9 +209,9 @@ class CheckedNumeric {
lhs.ValueUnsafe() OP rhs.ValueUnsafe(), \
GetRangeConstraint(rhs.validity() | lhs.validity())); \
RangeConstraint validity = RANGE_VALID; \
T result = Checked##NAME(static_cast<Promotion>(lhs.ValueUnsafe()), \
static_cast<Promotion>(rhs.ValueUnsafe()), \
&validity); \
T result = \
Checked##NAME(static_cast<Promotion>(lhs.ValueUnsafe()), \
static_cast<Promotion>(rhs.ValueUnsafe()), &validity); \
return CheckedNumeric<Promotion>( \
result, \
GetRangeConstraint(validity | lhs.validity() | rhs.validity())); \
......@@ -227,7 +227,7 @@ class CheckedNumeric {
template <typename T, typename Src> \
CheckedNumeric<typename ArithmeticPromotion<T, Src>::type> operator OP( \
const CheckedNumeric<Src>& lhs, const CheckedNumeric<T>& rhs) { \
typedef typename ArithmeticPromotion<T, Src>::type Promotion; \
using Promotion = typename ArithmeticPromotion<T, Src>::type; \
if (IsIntegerArithmeticSafe<Promotion, T, Src>::value) \
return CheckedNumeric<Promotion>( \
lhs.ValueUnsafe() OP rhs.ValueUnsafe(), \
......@@ -239,7 +239,7 @@ class CheckedNumeric {
template <typename T, typename Src> \
CheckedNumeric<typename ArithmeticPromotion<T, Src>::type> operator OP( \
const CheckedNumeric<T>& lhs, Src rhs) { \
typedef typename ArithmeticPromotion<T, Src>::type Promotion; \
using Promotion = typename ArithmeticPromotion<T, Src>::type; \
if (IsIntegerArithmeticSafe<Promotion, T, Src>::value) \
return CheckedNumeric<Promotion>(lhs.ValueUnsafe() OP rhs, \
lhs.validity()); \
......@@ -250,7 +250,7 @@ class CheckedNumeric {
template <typename T, typename Src> \
CheckedNumeric<typename ArithmeticPromotion<T, Src>::type> operator OP( \
Src lhs, const CheckedNumeric<T>& rhs) { \
typedef typename ArithmeticPromotion<T, Src>::type Promotion; \
using Promotion = typename ArithmeticPromotion<T, Src>::type; \
if (IsIntegerArithmeticSafe<Promotion, T, Src>::value) \
return CheckedNumeric<Promotion>(lhs OP rhs.ValueUnsafe(), \
rhs.validity()); \
......
......@@ -27,14 +27,14 @@ namespace internal {
template<class T, T v>
struct integral_constant {
static const T value = v;
typedef T value_type;
typedef integral_constant<T, v> type;
using value_type = T;
using type = integral_constant<T, v>;
};
template <class T, T v> const T integral_constant<T, v>::value;
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
using true_type = integral_constant<bool, true>;
using false_type = integral_constant<bool, false>;
template <class T, class U> struct is_same : public false_type {};
template <class T> struct is_same<T, T> : true_type {};
......@@ -42,8 +42,10 @@ template <class T> struct is_same<T, T> : true_type {};
template<bool B, class T = void>
struct enable_if {};
template<class T>
struct enable_if<true, T> { typedef T type; };
template <class T>
struct enable_if<true, T> {
using type = T;
};
// </template_util.h>
......@@ -57,35 +59,35 @@ template <size_t Size, bool IsSigned>
struct IntegerForSizeAndSign;
template <>
struct IntegerForSizeAndSign<1, true> {
typedef int8_t type;
using type = int8_t;
};
template <>
struct IntegerForSizeAndSign<1, false> {
typedef uint8_t type;
using type = uint8_t;
};
template <>
struct IntegerForSizeAndSign<2, true> {
typedef int16_t type;
using type = int16_t;
};
template <>
struct IntegerForSizeAndSign<2, false> {
typedef uint16_t type;
using type = uint16_t;
};
template <>
struct IntegerForSizeAndSign<4, true> {
typedef int32_t type;
using type = int32_t;
};
template <>
struct IntegerForSizeAndSign<4, false> {
typedef uint32_t type;
using type = uint32_t;
};
template <>
struct IntegerForSizeAndSign<8, true> {
typedef int64_t type;
using type = int64_t;
};
template <>
struct IntegerForSizeAndSign<8, false> {
typedef uint64_t type;
using type = uint64_t;
};
// WARNING: We have no IntegerForSizeAndSign<16, *>. If we ever add one to
......@@ -94,25 +96,25 @@ struct IntegerForSizeAndSign<8, false> {
template <typename Integer>
struct UnsignedIntegerForSize {
typedef typename enable_if<
using type = typename enable_if<
std::numeric_limits<Integer>::is_integer,
typename IntegerForSizeAndSign<sizeof(Integer), false>::type>::type type;
typename IntegerForSizeAndSign<sizeof(Integer), false>::type>::type;
};
template <typename Integer>
struct SignedIntegerForSize {
typedef typename enable_if<
using type = typename enable_if<
std::numeric_limits<Integer>::is_integer,
typename IntegerForSizeAndSign<sizeof(Integer), true>::type>::type type;
typename IntegerForSizeAndSign<sizeof(Integer), true>::type>::type;
};
template <typename Integer>
struct TwiceWiderInteger {
typedef typename enable_if<
using type = typename enable_if<
std::numeric_limits<Integer>::is_integer,
typename IntegerForSizeAndSign<
sizeof(Integer) * 2,
std::numeric_limits<Integer>::is_signed>::type>::type type;
std::numeric_limits<Integer>::is_signed>::type>::type;
};
template <typename Integer>
......@@ -145,7 +147,7 @@ typename enable_if<std::numeric_limits<T>::is_integer, T>::type
CheckedAdd(T x, T y, RangeConstraint* validity) {
// Since the value of x+y is undefined if we have a signed type, we compute
// it using the unsigned type of the same size.
typedef typename UnsignedIntegerForSize<T>::type UnsignedDst;
using UnsignedDst = typename UnsignedIntegerForSize<T>::type;
UnsignedDst ux = static_cast<UnsignedDst>(x);
UnsignedDst uy = static_cast<UnsignedDst>(y);
UnsignedDst uresult = ux + uy;
......@@ -168,7 +170,7 @@ typename enable_if<std::numeric_limits<T>::is_integer, T>::type
CheckedSub(T x, T y, RangeConstraint* validity) {
// Since the value of x+y is undefined if we have a signed type, we compute
// it using the unsigned type of the same size.
typedef typename UnsignedIntegerForSize<T>::type UnsignedDst;
using UnsignedDst = typename UnsignedIntegerForSize<T>::type;
UnsignedDst ux = static_cast<UnsignedDst>(x);
UnsignedDst uy = static_cast<UnsignedDst>(y);
UnsignedDst uresult = ux - uy;
......@@ -195,7 +197,7 @@ typename enable_if<
std::numeric_limits<T>::is_integer && sizeof(T) * 2 <= sizeof(uintmax_t),
T>::type
CheckedMul(T x, T y, RangeConstraint* validity) {
typedef typename TwiceWiderInteger<T>::type IntermediateType;
using IntermediateType = typename TwiceWiderInteger<T>::type;
IntermediateType tmp =
static_cast<IntermediateType>(x) * static_cast<IntermediateType>(y);
*validity = DstRangeRelationToSrcRange<T>(tmp);
......@@ -496,17 +498,17 @@ struct ArithmeticPromotion;
template <typename Lhs, typename Rhs>
struct ArithmeticPromotion<Lhs, Rhs, LEFT_PROMOTION> {
typedef Lhs type;
using type = Lhs;
};
template <typename Lhs, typename Rhs>
struct ArithmeticPromotion<Lhs, Rhs, RIGHT_PROMOTION> {
typedef Rhs type;
using type = Rhs;
};
template <typename Lhs, typename Rhs>
struct ArithmeticPromotion<Lhs, Rhs, DEFAULT_PROMOTION> {
typedef int type;
using type = int;
};
// We can statically check if operations on the provided types can wrap, so we
......
......@@ -39,7 +39,7 @@ class V8_BASE_EXPORT RandomNumberGenerator final {
public:
// EntropySource is used as a callback function when V8 needs a source of
// entropy.
typedef bool (*EntropySource)(unsigned char* buffer, size_t buflen);
using EntropySource = bool (*)(unsigned char* buffer, size_t buflen);
static void SetEntropySource(EntropySource entropy_source);
RandomNumberGenerator();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment