Fixes for C++20 support.

Various things are deprecated or removed in C++20, including
* Various allocator member types
* std::iterator
* std::result_of

Replace these with supported versions.

Bug: chromium:1284275
Change-Id: I11a2909e3a269cdb98ada2bd6621086409878242
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89040
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Peter Kasting <pkasting@google.com>
Commit-Queue: Peter Kasting <pkasting@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Peter Kasting 2022-05-05 17:00:31 +00:00 committed by Dawn LUCI CQ
parent 7cbd8202e6
commit d3921b8230
3 changed files with 11 additions and 4 deletions

View File

@ -34,8 +34,8 @@
template <typename T, size_t stack_capacity>
class StackAllocator : public std::allocator<T> {
public:
typedef typename std::allocator<T>::pointer pointer;
typedef typename std::allocator<T>::size_type size_type;
typedef typename std::allocator_traits<std::allocator<T>>::pointer pointer;
typedef typename std::allocator_traits<std::allocator<T>>::size_type size_type;
// Backing store for the allocator. The container owner is responsible for
// maintaining this for as long as any containers using this allocator are

View File

@ -53,8 +53,14 @@ class ParamGenerator {
}
}
class Iterator : public std::iterator<std::forward_iterator_tag, ParamStruct, size_t> {
class Iterator {
public:
using iterator_category = std::forward_iterator_tag;
using value_type = ParamStruct;
using difference_type = size_t;
using pointer = ParamStruct*;
using reference = ParamStruct&;
Iterator& operator++() {
// Increment the Index by 1. If the i'th place reaches the maximum,
// reset it to 0 and continue with the i+1'th place.

View File

@ -17,6 +17,7 @@
#include <algorithm>
#include <functional>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
@ -366,7 +367,7 @@ class CloneContext {
/// references of the original object. A type mismatch will result in an
/// assertion in debug builds, and undefined behavior in release builds.
/// @returns this CloneContext so calls can be chained
template <typename WHAT, typename WITH, typename = std::result_of_t<WITH()>>
template <typename WHAT, typename WITH, typename = std::invoke_result_t<WITH>>
CloneContext& Replace(const WHAT* what, WITH&& with) {
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, src, what);
replacements_[what] = with;