diff --git a/cache/clock_cache.cc b/cache/clock_cache.cc index 3364e25123..d2bcab0e26 100644 --- a/cache/clock_cache.cc +++ b/cache/clock_cache.cc @@ -260,7 +260,7 @@ struct CleanupContext { class ClockCacheShard final : public CacheShard { public: // Hash map type. - typedef tbb::concurrent_hash_map HashTable; + using HashTable = tbb::concurrent_hash_map; ClockCacheShard(); ~ClockCacheShard() override; diff --git a/db/compaction/compaction_picker_universal.cc b/db/compaction/compaction_picker_universal.cc index 211a4f468a..ef3c9589d3 100644 --- a/db/compaction/compaction_picker_universal.cc +++ b/db/compaction/compaction_picker_universal.cc @@ -157,9 +157,9 @@ struct SmallestKeyHeapComparator { const Comparator* ucmp_; }; -typedef std::priority_queue, - SmallestKeyHeapComparator> - SmallestKeyHeap; +using SmallestKeyHeap = + std::priority_queue, + SmallestKeyHeapComparator>; // This function creates the heap that is used to find if the files are // overlapping during universal compaction when the allow_trivial_move diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index 2d020fe6ce..40df71a75d 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -3116,7 +3116,7 @@ SnapshotImpl* DBImpl::GetSnapshotImpl(bool is_write_conflict_boundary, } namespace { -typedef autovector CfdList; +using CfdList = autovector; bool CfdListContains(const CfdList& list, ColumnFamilyData* cfd) { for (const ColumnFamilyData* t : list) { if (t == cfd) { diff --git a/db/db_impl/db_impl.h b/db/db_impl/db_impl.h index e558edc656..c2d7611045 100644 --- a/db/db_impl/db_impl.h +++ b/db/db_impl/db_impl.h @@ -1753,7 +1753,7 @@ class DBImpl : public DB { // specified value, this flush request is considered to have completed its // work of flushing this column family. After completing the work for all // column families in this request, this flush is considered complete. - typedef std::vector> FlushRequest; + using FlushRequest = std::vector>; void GenerateFlushRequest(const autovector& cfds, FlushRequest* req); diff --git a/db/db_test.cc b/db/db_test.cc index 9dbc9ecd53..0d8e479f41 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -2812,7 +2812,7 @@ TEST_F(DBTest, GroupCommitTest) { #endif // TRAVIS namespace { -typedef std::map KVMap; +using KVMap = std::map; } class ModelDB : public DB { diff --git a/db/forward_iterator.h b/db/forward_iterator.h index e094c66956..620d467810 100644 --- a/db/forward_iterator.h +++ b/db/forward_iterator.h @@ -39,8 +39,9 @@ class MinIterComparator { const Comparator* comparator_; }; -typedef std::priority_queue, - MinIterComparator> MinIterHeap; +using MinIterHeap = + std::priority_queue, + MinIterComparator>; /** * ForwardIterator is a special type of iterator that only supports Seek() diff --git a/db/kv_checksum.h b/db/kv_checksum.h index ba15dca3bb..725ddc6de4 100644 --- a/db/kv_checksum.h +++ b/db/kv_checksum.h @@ -49,10 +49,10 @@ template class ProtectionInfoKVOTS; // Aliases for 64-bit protection infos. -typedef ProtectionInfo ProtectionInfo64; -typedef ProtectionInfoKVOT ProtectionInfoKVOT64; -typedef ProtectionInfoKVOTC ProtectionInfoKVOTC64; -typedef ProtectionInfoKVOTS ProtectionInfoKVOTS64; +using ProtectionInfo64 = ProtectionInfo; +using ProtectionInfoKVOT64 = ProtectionInfoKVOT; +using ProtectionInfoKVOTC64 = ProtectionInfoKVOTC; +using ProtectionInfoKVOTS64 = ProtectionInfoKVOTS; template class ProtectionInfo { diff --git a/db/malloc_stats.cc b/db/malloc_stats.cc index 12824e5163..8f58ab2cfe 100644 --- a/db/malloc_stats.cc +++ b/db/malloc_stats.cc @@ -19,10 +19,10 @@ namespace ROCKSDB_NAMESPACE { #ifdef ROCKSDB_JEMALLOC -typedef struct { +struct MallocStatus { char* cur; char* end; -} MallocStatus; +}; static void GetJemallocStatus(void* mstat_arg, const char* status) { MallocStatus* mstat = reinterpret_cast(mstat_arg); diff --git a/db/pinned_iterators_manager.h b/db/pinned_iterators_manager.h index 5e8ad51dd0..1336f54200 100644 --- a/db/pinned_iterators_manager.h +++ b/db/pinned_iterators_manager.h @@ -43,7 +43,7 @@ class PinnedIteratorsManager : public Cleanable { } } - typedef void (*ReleaseFunction)(void* arg1); + using ReleaseFunction = void (*)(void* arg1); void PinPtr(void* ptr, ReleaseFunction release_func) { assert(pinning_enabled); if (ptr == nullptr) { diff --git a/env/env_basic_test.cc b/env/env_basic_test.cc index 3d74239444..9cd8a11e74 100644 --- a/env/env_basic_test.cc +++ b/env/env_basic_test.cc @@ -17,8 +17,9 @@ #include "test_util/testharness.h" namespace ROCKSDB_NAMESPACE { -typedef Env* CreateEnvFunc(); namespace { +using CreateEnvFunc = Env*(); + // These functions are used to create the various environments under which this // test can execute. These functions are used to allow the test cases to be // created without the Env being initialized, thereby eliminating a potential diff --git a/include/rocksdb/advanced_options.h b/include/rocksdb/advanced_options.h index 680c46317e..2e6bb7fbc4 100644 --- a/include/rocksdb/advanced_options.h +++ b/include/rocksdb/advanced_options.h @@ -650,8 +650,8 @@ struct AdvancedColumnFamilyOptions { // the tables. // Default: empty vector -- no user-defined statistics collection will be // performed. - typedef std::vector> - TablePropertiesCollectorFactories; + using TablePropertiesCollectorFactories = + std::vector>; TablePropertiesCollectorFactories table_properties_collector_factories; // Maximum number of successive merge operations on a key in the memtable. diff --git a/include/rocksdb/cache.h b/include/rocksdb/cache.h index c1ce88dbd8..b7ab36dc03 100644 --- a/include/rocksdb/cache.h +++ b/include/rocksdb/cache.h @@ -202,9 +202,6 @@ class Cache { // takes in a buffer from the NVM cache and constructs an object using // it. The callback doesn't have ownership of the buffer and should // copy the contents into its own buffer. - // typedef std::function - // CreateCallback; using CreateCallback = std::function; diff --git a/include/rocksdb/cleanable.h b/include/rocksdb/cleanable.h index b6a70ea642..c325ae2068 100644 --- a/include/rocksdb/cleanable.h +++ b/include/rocksdb/cleanable.h @@ -30,7 +30,7 @@ class Cleanable { // // Note that unlike all of the preceding methods, this method is // not abstract and therefore clients should not override it. - typedef void (*CleanupFunction)(void* arg1, void* arg2); + using CleanupFunction = void (*)(void* arg1, void* arg2); void RegisterCleanup(CleanupFunction function, void* arg1, void* arg2); void DelegateCleanupsTo(Cleanable* other); // DoCleanup and also resets the pointers for reuse diff --git a/include/rocksdb/db.h b/include/rocksdb/db.h index 264ff06f40..d749ea8f5c 100644 --- a/include/rocksdb/db.h +++ b/include/rocksdb/db.h @@ -136,8 +136,8 @@ struct GetMergeOperandsOptions { // A collections of table properties objects, where // key: is the table's file name. // value: the table properties object of the given table. -typedef std::unordered_map> - TablePropertiesCollection; +using TablePropertiesCollection = + std::unordered_map>; // A DB is a persistent, versioned ordered map from keys to values. // A DB is safe for concurrent access from multiple threads without diff --git a/include/rocksdb/listener.h b/include/rocksdb/listener.h index 5216e1e24a..a70836a272 100644 --- a/include/rocksdb/listener.h +++ b/include/rocksdb/listener.h @@ -21,8 +21,8 @@ namespace ROCKSDB_NAMESPACE { -typedef std::unordered_map> - TablePropertiesCollection; +using TablePropertiesCollection = + std::unordered_map>; class DB; class ColumnFamilyHandle; diff --git a/include/rocksdb/memtablerep.h b/include/rocksdb/memtablerep.h index 934a0085a2..a2eeba0413 100644 --- a/include/rocksdb/memtablerep.h +++ b/include/rocksdb/memtablerep.h @@ -51,7 +51,7 @@ class LookupKey; class SliceTransform; class Logger; -typedef void* KeyHandle; +using KeyHandle = void*; extern Slice GetLengthPrefixedSlice(const char* data); @@ -61,7 +61,7 @@ class MemTableRep { // concatenated with values. class KeyComparator { public: - typedef ROCKSDB_NAMESPACE::Slice DecodedType; + using DecodedType = ROCKSDB_NAMESPACE::Slice; virtual DecodedType decode_key(const char* key) const { // The format of key is frozen and can be treated as a part of the API diff --git a/include/rocksdb/persistent_cache.h b/include/rocksdb/persistent_cache.h index e2dcfcac3a..cff6c7ecd8 100644 --- a/include/rocksdb/persistent_cache.h +++ b/include/rocksdb/persistent_cache.h @@ -24,7 +24,7 @@ namespace ROCKSDB_NAMESPACE { // cache interface is specifically designed for persistent read cache. class PersistentCache { public: - typedef std::vector> StatsType; + using StatsType = std::vector>; virtual ~PersistentCache() {} diff --git a/include/rocksdb/table_properties.h b/include/rocksdb/table_properties.h index 2e605ee8d7..1906e7acc2 100644 --- a/include/rocksdb/table_properties.h +++ b/include/rocksdb/table_properties.h @@ -26,7 +26,7 @@ namespace ROCKSDB_NAMESPACE { // ++pos) { // ... // } -typedef std::map UserCollectedProperties; +using UserCollectedProperties = std::map; // table properties' human-readable names in the property block. struct TablePropertiesNames { diff --git a/include/rocksdb/transaction_log.h b/include/rocksdb/transaction_log.h index 48d0e5c0b8..2519f3a587 100644 --- a/include/rocksdb/transaction_log.h +++ b/include/rocksdb/transaction_log.h @@ -14,7 +14,7 @@ namespace ROCKSDB_NAMESPACE { class LogFile; -typedef std::vector> VectorLogPtr; +using VectorLogPtr = std::vector>; enum WalFileType { /* Indicates that WAL file is in archive directory. WAL files are moved from diff --git a/include/rocksdb/types.h b/include/rocksdb/types.h index 3b2d3f6946..14dc39ea3a 100644 --- a/include/rocksdb/types.h +++ b/include/rocksdb/types.h @@ -15,7 +15,7 @@ namespace ROCKSDB_NAMESPACE { using ColumnFamilyId = uint32_t; // Represents a sequence number in a WAL file. -typedef uint64_t SequenceNumber; +using SequenceNumber = uint64_t; const SequenceNumber kMinUnCommittedSeq = 1; // 0 is always committed diff --git a/include/rocksdb/utilities/backup_engine.h b/include/rocksdb/utilities/backup_engine.h index 8b9426e83e..8c2eb20833 100644 --- a/include/rocksdb/utilities/backup_engine.h +++ b/include/rocksdb/utilities/backup_engine.h @@ -285,7 +285,7 @@ struct BackupFileInfo { uint64_t size; }; -typedef uint32_t BackupID; +using BackupID = uint32_t; struct BackupInfo { BackupID backup_id = 0U; diff --git a/memory/arena.h b/memory/arena.h index a7ee4c6ab0..07fc435596 100644 --- a/memory/arena.h +++ b/memory/arena.h @@ -86,7 +86,7 @@ class Arena : public Allocator { // Number of bytes allocated in one block const size_t kBlockSize; // Array of new[] allocated memory blocks - typedef std::vector Blocks; + using Blocks = std::vector; Blocks blocks_; struct MmapInfo { diff --git a/memory/memory_usage.h b/memory/memory_usage.h index 15e8b87cde..9061d45eb4 100644 --- a/memory/memory_usage.h +++ b/memory/memory_usage.h @@ -14,7 +14,7 @@ namespace ROCKSDB_NAMESPACE { template size_t ApproximateMemoryUsage( const std::unordered_map& umap) { - typedef std::unordered_map Map; + using Map = std::unordered_map; return sizeof(umap) + // Size of all items plus a next pointer for each item. (sizeof(typename Map::value_type) + sizeof(void*)) * umap.size() + diff --git a/memtable/hash_linklist_rep.cc b/memtable/hash_linklist_rep.cc index 765ca9cbba..15bc648a27 100644 --- a/memtable/hash_linklist_rep.cc +++ b/memtable/hash_linklist_rep.cc @@ -22,9 +22,9 @@ namespace ROCKSDB_NAMESPACE { namespace { -typedef const char* Key; -typedef SkipList MemtableSkipList; -typedef std::atomic Pointer; +using Key = const char*; +using MemtableSkipList = SkipList; +using Pointer = std::atomic; // A data structure used as the header of a link list of a hash bucket. struct BucketHeader { diff --git a/memtable/hash_skiplist_rep.cc b/memtable/hash_skiplist_rep.cc index 67a2a6c83c..72fc391e17 100644 --- a/memtable/hash_skiplist_rep.cc +++ b/memtable/hash_skiplist_rep.cc @@ -46,7 +46,7 @@ class HashSkipListRep : public MemTableRep { private: friend class DynamicIterator; - typedef SkipList Bucket; + using Bucket = SkipList; size_t bucket_size_; diff --git a/memtable/inlineskiplist_test.cc b/memtable/inlineskiplist_test.cc index 75b83f46ed..4523aa7704 100644 --- a/memtable/inlineskiplist_test.cc +++ b/memtable/inlineskiplist_test.cc @@ -19,7 +19,7 @@ namespace ROCKSDB_NAMESPACE { // Our test skip list stores 8-byte unsigned integers -typedef uint64_t Key; +using Key = uint64_t; static const char* Encode(const uint64_t* key) { return reinterpret_cast(key); @@ -32,7 +32,7 @@ static Key Decode(const char* key) { } struct TestComparator { - typedef Key DecodedType; + using DecodedType = Key; static DecodedType decode_key(const char* b) { return Decode(b); @@ -59,7 +59,7 @@ struct TestComparator { } }; -typedef InlineSkipList TestInlineSkipList; +using TestInlineSkipList = InlineSkipList; class InlineSkipTest : public testing::Test { public: diff --git a/memtable/skiplist_test.cc b/memtable/skiplist_test.cc index 18990eab5c..d35bc856d8 100644 --- a/memtable/skiplist_test.cc +++ b/memtable/skiplist_test.cc @@ -17,7 +17,7 @@ namespace ROCKSDB_NAMESPACE { -typedef uint64_t Key; +using Key = uint64_t; struct TestComparator { int operator()(const Key& a, const Key& b) const { diff --git a/memtable/vectorrep.cc b/memtable/vectorrep.cc index 3797e46c45..7dde80b229 100644 --- a/memtable/vectorrep.cc +++ b/memtable/vectorrep.cc @@ -98,7 +98,7 @@ class VectorRep : public MemTableRep { private: friend class Iterator; - typedef std::vector Bucket; + using Bucket = std::vector; std::shared_ptr bucket_; mutable port::RWMutex rwlock_; bool immutable_; diff --git a/options/cf_options.cc b/options/cf_options.cc index 465413170d..996aefab59 100644 --- a/options/cf_options.cc +++ b/options/cf_options.cc @@ -479,8 +479,8 @@ static std::unordered_map /* not yet supported CompressionOptions compression_opts; TablePropertiesCollectorFactories table_properties_collector_factories; - typedef std::vector> - TablePropertiesCollectorFactories; + using TablePropertiesCollectorFactories = + std::vector>; UpdateStatus (*inplace_callback)(char* existing_value, uint34_t* existing_value_size, Slice delta_value, diff --git a/options/options_settable_test.cc b/options/options_settable_test.cc index 5c79a02485..f79021374b 100644 --- a/options/options_settable_test.cc +++ b/options/options_settable_test.cc @@ -41,7 +41,7 @@ class OptionsSettableTest : public testing::Test { }; const char kSpecialChar = 'z'; -typedef std::vector> OffsetGap; +using OffsetGap = std::vector>; void FillWithSpecialChar(char* start_ptr, size_t total_size, const OffsetGap& excluded, diff --git a/port/port_example.h b/port/port_example.h index b906bbec7a..794149a690 100644 --- a/port/port_example.h +++ b/port/port_example.h @@ -70,7 +70,7 @@ class CondVar { // static void Initializer() { ... do something ...; } // ... // port::InitOnce(&init_control, &Initializer); -typedef intptr_t OnceType; +using OnceType = intptr_t; #define LEVELDB_ONCE_INIT 0 extern void InitOnce(port::OnceType*, void (*initializer)()); diff --git a/port/port_posix.h b/port/port_posix.h index 9bea210397..291139764a 100644 --- a/port/port_posix.h +++ b/port/port_posix.h @@ -177,7 +177,7 @@ static inline void AsmVolatilePause() { // Returns -1 if not available on this platform extern int PhysicalCoreID(); -typedef pthread_once_t OnceType; +using OnceType = pthread_once_t; #define LEVELDB_ONCE_INIT PTHREAD_ONCE_INIT extern void InitOnce(OnceType* once, void (*initializer)()); diff --git a/port/sys_time.h b/port/sys_time.h index 1c7d206a79..8a5440f955 100644 --- a/port/sys_time.h +++ b/port/sys_time.h @@ -23,10 +23,10 @@ namespace ROCKSDB_NAMESPACE { namespace port { // Avoid including winsock2.h for this definition -typedef struct timeval { +struct timeval { long tv_sec; long tv_usec; -} timeval; +}; void gettimeofday(struct timeval* tv, struct timezone* tz); diff --git a/port/win/env_win.cc b/port/win/env_win.cc index 2b141c55d6..53c32ed2d3 100644 --- a/port/win/env_win.cc +++ b/port/win/env_win.cc @@ -53,10 +53,10 @@ static const size_t kSectorSize = 512; // RAII helpers for HANDLEs const auto CloseHandleFunc = [](HANDLE h) { ::CloseHandle(h); }; -typedef std::unique_ptr UniqueCloseHandlePtr; +using UniqueCloseHandlePtr = std::unique_ptr; const auto FindCloseFunc = [](HANDLE h) { ::FindClose(h); }; -typedef std::unique_ptr UniqueFindClosePtr; +using UniqueFindClosePtr = std::unique_ptr; void WinthreadCall(const char* label, std::error_code result) { if (0 != result.value()) { diff --git a/port/win/env_win.h b/port/win/env_win.h index d0fd78ebbf..82902d73c4 100644 --- a/port/win/env_win.h +++ b/port/win/env_win.h @@ -96,7 +96,7 @@ class WinClock : public SystemClock { uint64_t GetPerfCounterFrequency() const { return perf_counter_frequency_; } private: - typedef VOID(WINAPI* FnGetSystemTimePreciseAsFileTime)(LPFILETIME); + using FnGetSystemTimePreciseAsFileTime = VOID(WINAPI*)(LPFILETIME); uint64_t perf_counter_frequency_; uint64_t nano_seconds_per_period_; diff --git a/port/win/port_win.h b/port/win/port_win.h index 2de75179d6..d188612cd7 100644 --- a/port/win/port_win.h +++ b/port/win/port_win.h @@ -47,7 +47,7 @@ #undef DeleteFile #ifndef _SSIZE_T_DEFINED -typedef SSIZE_T ssize_t; +using ssize_t = SSIZE_T; #endif // size_t printf formatting named in the manner of C99 standard formatting @@ -292,7 +292,7 @@ static inline void AsmVolatilePause() { extern int PhysicalCoreID(); // For Thread Local Storage abstraction -typedef DWORD pthread_key_t; +using pthread_key_t = DWORD; inline int pthread_key_create(pthread_key_t* key, void (*destructor)(void*)) { // Not used diff --git a/port/win/win_thread.h b/port/win/win_thread.h index ffdfdc11b6..89cfd02217 100644 --- a/port/win/win_thread.h +++ b/port/win/win_thread.h @@ -25,11 +25,10 @@ namespace port { // -- is that it dynamically allocates its internals that are automatically // freed when the thread terminates and not on the destruction of the // object. This makes it difficult to control the source of memory -// allocation +// allocation // - This implements Pimpl so we can easily replace the guts of the // object in our private version if necessary. class WindowsThread { - struct Data; std::shared_ptr data_; @@ -37,15 +36,14 @@ class WindowsThread { void Init(std::function&&); -public: - - typedef void* native_handle_type; + public: + using native_handle_type = void*; // Construct with no thread WindowsThread(); // Template constructor - // + // // This templated constructor accomplishes several things // // - Allows the class as whole to be not a template @@ -68,17 +66,12 @@ public: // dependent type that both checks the signature conformance to ensure // that all of the necessary arguments are provided and allows pimpl // implementation. - template::type, - WindowsThread>::value>::type> - explicit WindowsThread(Fn&& fx, Args&&... ax) : - WindowsThread() { - + template ::type, WindowsThread>::value>::type> + explicit WindowsThread(Fn&& fx, Args&&... ax) : WindowsThread() { // Use binder to create a single callable entity - auto binder = std::bind(std::forward(fx), - std::forward(ax)...); + auto binder = std::bind(std::forward(fx), std::forward(ax)...); // Use std::function to take advantage of the type erasure // so we can still hide implementation within pimpl // This also makes sure that the binder signature is compliant @@ -87,7 +80,6 @@ public: Init(std::move(target)); } - ~WindowsThread(); WindowsThread(const WindowsThread&) = delete; diff --git a/table/block_based/block_based_table_builder.cc b/table/block_based/block_based_table_builder.cc index d2b30443e0..be2cae968c 100644 --- a/table/block_based/block_based_table_builder.cc +++ b/table/block_based/block_based_table_builder.cc @@ -589,11 +589,11 @@ struct BlockBasedTableBuilder::ParallelCompressionRep { // Use a vector of BlockRep as a buffer for a determined number // of BlockRep structures. All data referenced by pointers in // BlockRep will be freed when this vector is destructed. - typedef std::vector BlockRepBuffer; + using BlockRepBuffer = std::vector; BlockRepBuffer block_rep_buf; // Use a thread-safe queue for concurrent access from block // building thread and writer thread. - typedef WorkQueue BlockRepPool; + using BlockRepPool = WorkQueue; BlockRepPool block_rep_pool; // Use BlockRepSlot to keep block order in write thread. @@ -617,7 +617,7 @@ struct BlockBasedTableBuilder::ParallelCompressionRep { // Compression queue will pass references to BlockRep in block_rep_buf, // and those references are always valid before the destruction of // block_rep_buf. - typedef WorkQueue CompressQueue; + using CompressQueue = WorkQueue; CompressQueue compress_queue; std::vector compress_thread_pool; @@ -625,7 +625,7 @@ struct BlockBasedTableBuilder::ParallelCompressionRep { // and those references are always valid before the corresponding // BlockRep::slot is destructed, which is before the destruction of // block_rep_buf. - typedef WorkQueue WriteQueue; + using WriteQueue = WorkQueue; WriteQueue write_queue; std::unique_ptr write_thread; diff --git a/table/block_based/block_based_table_reader.h b/table/block_based/block_based_table_reader.h index e64d09d209..287b60fd24 100644 --- a/table/block_based/block_based_table_reader.h +++ b/table/block_based/block_based_table_reader.h @@ -41,7 +41,7 @@ struct EnvOptions; struct ReadOptions; class GetContext; -typedef std::vector> KVPairBlock; +using KVPairBlock = std::vector>; // Reader class for BlockBasedTable format. // For the format of BlockBasedTable refer to diff --git a/table/merging_iterator.cc b/table/merging_iterator.cc index fdd1a4910d..ee938e93c3 100644 --- a/table/merging_iterator.cc +++ b/table/merging_iterator.cc @@ -28,8 +28,8 @@ namespace ROCKSDB_NAMESPACE { // Without anonymous namespace here, we fail the warning -Wmissing-prototypes namespace { -typedef BinaryHeap MergerMaxIterHeap; -typedef BinaryHeap MergerMinIterHeap; +using MergerMaxIterHeap = BinaryHeap; +using MergerMinIterHeap = BinaryHeap; } // namespace const size_t kNumIterReserve = 4; diff --git a/table/multiget_context.h b/table/multiget_context.h index 1c9f8da940..3872353d2f 100644 --- a/table/multiget_context.h +++ b/table/multiget_context.h @@ -158,12 +158,12 @@ class MultiGetContext { class Iterator { public: // -- iterator traits - typedef Iterator self_type; - typedef KeyContext value_type; - typedef KeyContext& reference; - typedef KeyContext* pointer; - typedef int difference_type; - typedef std::forward_iterator_tag iterator_category; + using self_type = Iterator; + using value_type = KeyContext; + using reference = KeyContext&; + using pointer = KeyContext*; + using difference_type = int; + using iterator_category = std::forward_iterator_tag; Iterator(const Range* range, size_t idx) : range_(range), ctx_(range->ctx_), index_(idx) { diff --git a/util/autovector.h b/util/autovector.h index 7e33e5ca87..e2506a5ad2 100644 --- a/util/autovector.h +++ b/util/autovector.h @@ -51,25 +51,25 @@ template class autovector { public: // General STL-style container member types. - typedef T value_type; - typedef typename std::vector::difference_type difference_type; - typedef typename std::vector::size_type size_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef value_type* pointer; - typedef const value_type* const_pointer; + using value_type = T; + using difference_type = typename std::vector::difference_type; + using size_type = typename std::vector::size_type; + using reference = value_type&; + using const_reference = const value_type&; + using pointer = value_type*; + using const_pointer = const value_type*; // This class is the base for regular/const iterator template class iterator_impl { public: // -- iterator traits - typedef iterator_impl self_type; - typedef TValueType value_type; - typedef TValueType& reference; - typedef TValueType* pointer; - typedef typename TAutoVector::difference_type difference_type; - typedef std::random_access_iterator_tag iterator_category; + using self_type = iterator_impl; + using value_type = TValueType; + using reference = TValueType&; + using pointer = TValueType*; + using difference_type = typename TAutoVector::difference_type; + using iterator_category = std::random_access_iterator_tag; iterator_impl(TAutoVector* vect, size_t index) : vect_(vect), index_(index) {}; @@ -175,10 +175,10 @@ class autovector { size_t index_ = 0; }; - typedef iterator_impl iterator; - typedef iterator_impl const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + using iterator = iterator_impl; + using const_iterator = iterator_impl; + using reverse_iterator = std::reverse_iterator; + using const_reverse_iterator = std::reverse_iterator; autovector() : values_(reinterpret_cast(buf_)) {} diff --git a/util/autovector_test.cc b/util/autovector_test.cc index adddd1b028..d73b1ee6ab 100644 --- a/util/autovector_test.cc +++ b/util/autovector_test.cc @@ -64,7 +64,7 @@ TEST_F(AutoVectorTest, PushBackAndPopBack) { } TEST_F(AutoVectorTest, EmplaceBack) { - typedef std::pair ValType; + using ValType = std::pair; autovector vec; for (size_t i = 0; i < 1000 * kSize; ++i) { diff --git a/util/crc32c.cc b/util/crc32c.cc index 87fbb9f84f..59acb8c72b 100644 --- a/util/crc32c.cc +++ b/util/crc32c.cc @@ -459,7 +459,7 @@ static bool isPCLMULQDQ() { #endif // HAVE_POWER8 #endif // HAVE_ARM64_CRC -typedef uint32_t (*Function)(uint32_t, const char*, size_t); +using Function = uint32_t (*)(uint32_t, const char*, size_t); #if defined(HAVE_POWER8) && defined(HAS_ALTIVEC) uint32_t ExtendPPCImpl(uint32_t crc, const char *buf, size_t size) { @@ -1320,7 +1320,7 @@ struct gf_powers_memo<0, m> { template struct integer_sequence { - typedef T value_type; + using value_type = T; static constexpr size_t size() { return sizeof...(Ints); } }; diff --git a/util/kv_map.h b/util/kv_map.h index 0f713ccea1..89300d7ac8 100644 --- a/util/kv_map.h +++ b/util/kv_map.h @@ -28,6 +28,6 @@ struct LessOfComparator { const Comparator* cmp; }; -typedef std::map KVMap; +using KVMap = std::map; } } // namespace ROCKSDB_NAMESPACE diff --git a/util/murmurhash.h b/util/murmurhash.h index 1dbb573981..5f66c4ebf0 100644 --- a/util/murmurhash.h +++ b/util/murmurhash.h @@ -17,19 +17,19 @@ #define MURMUR_HASH MurmurHash64A uint64_t MurmurHash64A ( const void * key, int len, unsigned int seed ); #define MurmurHash MurmurHash64A -typedef uint64_t murmur_t; +using murmur_t = uint64_t; #elif defined(__i386__) #define MURMUR_HASH MurmurHash2 unsigned int MurmurHash2 ( const void * key, int len, unsigned int seed ); #define MurmurHash MurmurHash2 -typedef unsigned int murmur_t; +using murmur_t = unsigned int; #else #define MURMUR_HASH MurmurHashNeutral2 unsigned int MurmurHashNeutral2 ( const void * key, int len, unsigned int seed ); #define MurmurHash MurmurHashNeutral2 -typedef unsigned int murmur_t; +using murmur_t = unsigned int; #endif // Allow slice to be hashable by murmur hash. diff --git a/util/thread_local.h b/util/thread_local.h index c4b762ab6f..01790ccc08 100644 --- a/util/thread_local.h +++ b/util/thread_local.h @@ -31,7 +31,7 @@ namespace ROCKSDB_NAMESPACE { // is needed to avoid deadlocks. In particular, the handler shouldn't lock any // mutexes and shouldn't call any methods of any ThreadLocalPtr instances, // unless you know what you're doing. -typedef void (*UnrefHandler)(void* ptr); +using UnrefHandler = void (*)(void* ptr); // ThreadLocalPtr stores only values of pointer type. Different from // the usual thread-local-storage, ThreadLocalPtr has the ability to @@ -69,7 +69,7 @@ class ThreadLocalPtr { // data for all existing threads void Scrape(autovector* ptrs, void* const replacement); - typedef std::function FoldFunc; + using FoldFunc = std::function; // Update res by applying func on each thread-local value. Holds a lock that // prevents unref handler from running during this call, but clients must // still provide external synchronization since the owning thread can diff --git a/utilities/cassandra/format.h b/utilities/cassandra/format.h index 325ebb4e69..2aca9d3f93 100644 --- a/utilities/cassandra/format.h +++ b/utilities/cassandra/format.h @@ -142,7 +142,7 @@ private: std::chrono::seconds Ttl() const; }; -typedef std::vector> Columns; +using Columns = std::vector>; class RowValue { public: diff --git a/utilities/env_librados_test.cc b/utilities/env_librados_test.cc index d5167acc00..3b86881ac1 100644 --- a/utilities/env_librados_test.cc +++ b/utilities/env_librados_test.cc @@ -20,9 +20,10 @@ #include "rocksdb/utilities/transaction_db.h" class Timer { - typedef std::chrono::high_resolution_clock high_resolution_clock; - typedef std::chrono::milliseconds milliseconds; -public: + using high_resolution_clock = std::chrono::high_resolution_clock; + using milliseconds = std::chrono::milliseconds; + + public: explicit Timer(bool run = false) { if (run) diff --git a/utilities/merge_operators/string_append/stringappend_test.cc b/utilities/merge_operators/string_append/stringappend_test.cc index f7d8d7bff7..e7963364e1 100644 --- a/utilities/merge_operators/string_append/stringappend_test.cc +++ b/utilities/merge_operators/string_append/stringappend_test.cc @@ -149,7 +149,7 @@ class StringAppendOperatorTest : public testing::Test, StringAppendOperatorTest::SetOpenDbFunction(&OpenNormalDb); } - typedef std::shared_ptr (*OpenFuncPtr)(const std::string&); + using OpenFuncPtr = std::shared_ptr (*)(const std::string&); // Allows user to open databases with different configurations. // e.g.: Can open a DB or a TtlDB, etc. diff --git a/utilities/persistent_cache/block_cache_tier_file.h b/utilities/persistent_cache/block_cache_tier_file.h index 95be4ec3cc..123f91e6c2 100644 --- a/utilities/persistent_cache/block_cache_tier_file.h +++ b/utilities/persistent_cache/block_cache_tier_file.h @@ -65,7 +65,7 @@ struct LogicalBlockAddress { uint32_t size_ = 0; }; -typedef LogicalBlockAddress LBA; +using LBA = LogicalBlockAddress; // class Writer // diff --git a/utilities/persistent_cache/block_cache_tier_metadata.h b/utilities/persistent_cache/block_cache_tier_metadata.h index 92adae2bf8..6735ce290a 100644 --- a/utilities/persistent_cache/block_cache_tier_metadata.h +++ b/utilities/persistent_cache/block_cache_tier_metadata.h @@ -95,9 +95,9 @@ class BlockCacheTierMetadata { } }; - typedef EvictableHashTable - CacheFileIndexType; + using CacheFileIndexType = + EvictableHashTable; // Block Lookup Index // @@ -114,7 +114,7 @@ class BlockCacheTierMetadata { } }; - typedef HashTable BlockIndexType; + using BlockIndexType = HashTable; CacheFileIndexType cache_file_index_; BlockIndexType block_index_; diff --git a/utilities/persistent_cache/hash_table_evictable.h b/utilities/persistent_cache/hash_table_evictable.h index d27205d088..e10939b2f7 100644 --- a/utilities/persistent_cache/hash_table_evictable.h +++ b/utilities/persistent_cache/hash_table_evictable.h @@ -24,7 +24,7 @@ namespace ROCKSDB_NAMESPACE { template class EvictableHashTable : private HashTable { public: - typedef HashTable hash_table; + using hash_table = HashTable; explicit EvictableHashTable(const size_t capacity = 1024 * 1024, const float load_factor = 2.0, @@ -141,7 +141,7 @@ class EvictableHashTable : private HashTable { port::RWMutex* GetMutex(T* t) { return hash_table::GetMutex(t); } private: - typedef LRUList LRUListType; + using LRUListType = LRUList; typename hash_table::Bucket& GetBucket(const uint64_t h) { const uint32_t bucket_idx = h % hash_table::nbuckets_; diff --git a/utilities/persistent_cache/persistent_cache_tier.h b/utilities/persistent_cache/persistent_cache_tier.h index 286436da07..65aadcd3f4 100644 --- a/utilities/persistent_cache/persistent_cache_tier.h +++ b/utilities/persistent_cache/persistent_cache_tier.h @@ -235,7 +235,7 @@ struct PersistentCacheConfig { // to enable management and stacking of tiers. class PersistentCacheTier : public PersistentCache { public: - typedef std::shared_ptr Tier; + using Tier = std::shared_ptr; virtual ~PersistentCacheTier() {} diff --git a/utilities/persistent_cache/volatile_tier_impl.h b/utilities/persistent_cache/volatile_tier_impl.h index 6116e894bf..d6dbcdef4e 100644 --- a/utilities/persistent_cache/volatile_tier_impl.h +++ b/utilities/persistent_cache/volatile_tier_impl.h @@ -124,8 +124,8 @@ class VolatileCacheTier : public PersistentCacheTier { } }; - typedef EvictableHashTable - IndexType; + using IndexType = + EvictableHashTable; // Evict LRU tail bool Evict(); diff --git a/utilities/transactions/lock/point/point_lock_manager.h b/utilities/transactions/lock/point/point_lock_manager.h index 3c541eb3af..c861061fcd 100644 --- a/utilities/transactions/lock/point/point_lock_manager.h +++ b/utilities/transactions/lock/point/point_lock_manager.h @@ -98,7 +98,7 @@ class DeadlockInfoBufferTempl { } }; -typedef DeadlockInfoBufferTempl DeadlockInfoBuffer; +using DeadlockInfoBuffer = DeadlockInfoBufferTempl; struct TrackedTrxInfo { autovector m_neighbors; diff --git a/utilities/transactions/lock/point/point_lock_manager_test.h b/utilities/transactions/lock/point/point_lock_manager_test.h index d4011c0241..50b268ab16 100644 --- a/utilities/transactions/lock/point/point_lock_manager_test.h +++ b/utilities/transactions/lock/point/point_lock_manager_test.h @@ -78,7 +78,7 @@ class PointLockManagerTest : public testing::Test { TransactionDB* db_; }; -typedef void (*init_func_t)(PointLockManagerTest*); +using init_func_t = void (*)(PointLockManagerTest*); class AnyLockManagerTest : public PointLockManagerTest, public testing::WithParamInterface { diff --git a/utilities/ttl/ttl_test.cc b/utilities/ttl/ttl_test.cc index c657dfe2b5..e0b5ee00b1 100644 --- a/utilities/ttl/ttl_test.cc +++ b/utilities/ttl/ttl_test.cc @@ -25,7 +25,7 @@ namespace ROCKSDB_NAMESPACE { namespace { -typedef std::map KVMap; +using KVMap = std::map; enum BatchOperation { OP_PUT = 0, OP_DELETE = 1 }; } diff --git a/utilities/write_batch_with_index/write_batch_with_index_internal.h b/utilities/write_batch_with_index/write_batch_with_index_internal.h index b3360140bf..8085f5f50d 100644 --- a/utilities/write_batch_with_index/write_batch_with_index_internal.h +++ b/utilities/write_batch_with_index/write_batch_with_index_internal.h @@ -174,8 +174,8 @@ class WriteBatchEntryComparator { const ReadableWriteBatch* write_batch_; }; -typedef SkipList - WriteBatchEntrySkipList; +using WriteBatchEntrySkipList = + SkipList; class WBWIIteratorImpl : public WBWIIterator { public: