From 446b1a7df14cb98923a688caadf31fefa9daa9ff Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 15 Jun 2022 21:36:27 +0000 Subject: [PATCH] tint/clone_context.h: Template the vector allocator type Currently nothing in Tint uses a different allocator type, but this allows the CloneContext to support different allocators, the day we do. Change-Id: I70367bd3710128d0708b3369f66b441344b789f8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93602 Reviewed-by: Dan Sinclair Commit-Queue: Ben Clayton --- src/tint/clone_context.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/tint/clone_context.h b/src/tint/clone_context.h index e027565aa1..887d628fe8 100644 --- a/src/tint/clone_context.h +++ b/src/tint/clone_context.h @@ -156,8 +156,8 @@ class CloneContext { /// /// @param v the vector to clone /// @return the cloned vector - template - std::vector Clone(const std::vector& v) { + template + std::vector Clone(const std::vector& v) { std::vector out; out.reserve(v.size()); for (auto& el : v) { @@ -174,9 +174,9 @@ class CloneContext { /// /// @param v the vector to clone /// @return the cloned vector - template - std::vector Clone(const std::vector& v) { - std::vector out; + template + std::vector Clone(const std::vector& v) { + std::vector out; Clone(out, v); return out; } @@ -189,8 +189,8 @@ class CloneContext { /// /// @param from the vector to clone /// @param to the cloned result - template - void Clone(std::vector& to, const std::vector& from) { + template + void Clone(std::vector& to, const std::vector& from) { to.reserve(from.size()); auto list_transform_it = list_transforms_.find(&from); @@ -379,8 +379,8 @@ class CloneContext { /// @param object a pointer to the object in #src that will be omitted from /// the cloned vector. /// @returns this CloneContext so calls can be chained - template - CloneContext& Remove(const std::vector& vector, OBJECT* object) { + template + CloneContext& Remove(const std::vector& vector, OBJECT* object) { TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, src, object); if (std::find(vector.begin(), vector.end(), object) == vector.end()) { TINT_ICE(Clone, Diagnostics()) @@ -397,8 +397,8 @@ class CloneContext { /// @param object a pointer to the object in #dst that will be inserted at the /// front of the vector /// @returns this CloneContext so calls can be chained - template - CloneContext& InsertFront(const std::vector& vector, OBJECT* object) { + template + CloneContext& InsertFront(const std::vector& vector, OBJECT* object) { TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, dst, object); auto& transforms = list_transforms_[&vector]; auto& list = transforms.insert_front_; @@ -411,8 +411,8 @@ class CloneContext { /// @param object a pointer to the object in #dst that will be inserted at the /// end of the vector /// @returns this CloneContext so calls can be chained - template - CloneContext& InsertBack(const std::vector& vector, OBJECT* object) { + template + CloneContext& InsertBack(const std::vector& vector, OBJECT* object) { TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, dst, object); auto& transforms = list_transforms_[&vector]; auto& list = transforms.insert_back_; @@ -426,8 +426,8 @@ class CloneContext { /// @param object a pointer to the object in #dst that will be inserted before /// any occurrence of the clone of `before` /// @returns this CloneContext so calls can be chained - template - CloneContext& InsertBefore(const std::vector& vector, + template + CloneContext& InsertBefore(const std::vector& vector, const BEFORE* before, const OBJECT* object) { TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, src, before); @@ -450,8 +450,8 @@ class CloneContext { /// @param object a pointer to the object in #dst that will be inserted after /// any occurrence of the clone of `after` /// @returns this CloneContext so calls can be chained - template - CloneContext& InsertAfter(const std::vector& vector, + template + CloneContext& InsertAfter(const std::vector& vector, const AFTER* after, const OBJECT* object) { TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, src, after);