From d867019dcb0d9b428b8cec1572fdf6caa267e665 Mon Sep 17 00:00:00 2001 From: Lofty Date: Wed, 3 Jan 2024 13:19:42 +0000 Subject: [PATCH] upgrade to C++17 --- CMakeLists.txt | 2 +- common/kernel/hashlib.h | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d24a5d5f..5b4604a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,7 +141,7 @@ foreach(item ${ARCH}) endif() endforeach() -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) if (MSVC) set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /W4 /wd4100 /wd4244 /wd4125 /wd4800 /wd4456 /wd4458 /wd4305 /wd4459 /wd4121 /wd4996") diff --git a/common/kernel/hashlib.h b/common/kernel/hashlib.h index 008a581e..884fcdcc 100644 --- a/common/kernel/hashlib.h +++ b/common/kernel/hashlib.h @@ -367,7 +367,7 @@ template class dict using mapped_type = T; using value_type = std::pair; - class const_iterator : public std::iterator> + class const_iterator { friend class dict; @@ -377,6 +377,11 @@ template class dict const_iterator(const dict *ptr, int index) : ptr(ptr), index(index) {} public: + using iterator_category = std::forward_iterator_tag; + using value_type = std::pair; + using difference_type = std::ptrdiff_t; + using pointer = std::pair*; + using reference = std::pair&; const_iterator() {} const_iterator operator++() { @@ -395,7 +400,7 @@ template class dict const std::pair *operator->() const { return &ptr->entries[index].udata; } }; - class iterator : public std::iterator> + class iterator { friend class dict; @@ -405,6 +410,11 @@ template class dict iterator(dict *ptr, int index) : ptr(ptr), index(index) {} public: + using iterator_category = std::forward_iterator_tag; + using value_type = std::pair; + using difference_type = std::ptrdiff_t; + using pointer = std::pair*; + using reference = std::pair&; iterator() {} iterator operator++() { @@ -808,7 +818,7 @@ template class pool } public: - class const_iterator : public std::iterator + class const_iterator { friend class pool; @@ -818,6 +828,11 @@ template class pool const_iterator(const pool *ptr, int index) : ptr(ptr), index(index) {} public: + using iterator_category = std::forward_iterator_tag; + using value_type = K; + using difference_type = std::ptrdiff_t; + using pointer = K*; + using reference = K&; const_iterator() {} const_iterator operator++() { @@ -830,7 +845,7 @@ template class pool const K *operator->() const { return &ptr->entries[index].udata; } }; - class iterator : public std::iterator + class iterator { friend class pool; @@ -840,6 +855,11 @@ template class pool iterator(pool *ptr, int index) : ptr(ptr), index(index) {} public: + using iterator_category = std::forward_iterator_tag; + using value_type = K; + using difference_type = std::ptrdiff_t; + using pointer = K*; + using reference = K&; iterator() {} iterator operator++() { @@ -1035,7 +1055,7 @@ template class idict pool database; public: - class const_iterator : public std::iterator + class const_iterator { friend class idict; @@ -1045,6 +1065,11 @@ template class idict const_iterator(const idict &container, int index) : container(container), index(index) {} public: + using iterator_category = std::forward_iterator_tag; + using value_type = K; + using difference_type = std::ptrdiff_t; + using pointer = K*; + using reference = K&; const_iterator() {} const_iterator operator++() {