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 <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
parent
2032d03400
commit
446b1a7df1
|
@ -156,8 +156,8 @@ class CloneContext {
|
||||||
///
|
///
|
||||||
/// @param v the vector to clone
|
/// @param v the vector to clone
|
||||||
/// @return the cloned vector
|
/// @return the cloned vector
|
||||||
template <typename T>
|
template <typename T, typename A>
|
||||||
std::vector<T> Clone(const std::vector<T>& v) {
|
std::vector<T> Clone(const std::vector<T, A>& v) {
|
||||||
std::vector<T> out;
|
std::vector<T> out;
|
||||||
out.reserve(v.size());
|
out.reserve(v.size());
|
||||||
for (auto& el : v) {
|
for (auto& el : v) {
|
||||||
|
@ -174,9 +174,9 @@ class CloneContext {
|
||||||
///
|
///
|
||||||
/// @param v the vector to clone
|
/// @param v the vector to clone
|
||||||
/// @return the cloned vector
|
/// @return the cloned vector
|
||||||
template <typename T>
|
template <typename T, typename A>
|
||||||
std::vector<T*> Clone(const std::vector<T*>& v) {
|
std::vector<T*, A> Clone(const std::vector<T*, A>& v) {
|
||||||
std::vector<T*> out;
|
std::vector<T*, A> out;
|
||||||
Clone(out, v);
|
Clone(out, v);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -189,8 +189,8 @@ class CloneContext {
|
||||||
///
|
///
|
||||||
/// @param from the vector to clone
|
/// @param from the vector to clone
|
||||||
/// @param to the cloned result
|
/// @param to the cloned result
|
||||||
template <typename T>
|
template <typename T, typename A>
|
||||||
void Clone(std::vector<T*>& to, const std::vector<T*>& from) {
|
void Clone(std::vector<T*, A>& to, const std::vector<T*, A>& from) {
|
||||||
to.reserve(from.size());
|
to.reserve(from.size());
|
||||||
|
|
||||||
auto list_transform_it = list_transforms_.find(&from);
|
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
|
/// @param object a pointer to the object in #src that will be omitted from
|
||||||
/// the cloned vector.
|
/// the cloned vector.
|
||||||
/// @returns this CloneContext so calls can be chained
|
/// @returns this CloneContext so calls can be chained
|
||||||
template <typename T, typename OBJECT>
|
template <typename T, typename A, typename OBJECT>
|
||||||
CloneContext& Remove(const std::vector<T>& vector, OBJECT* object) {
|
CloneContext& Remove(const std::vector<T, A>& vector, OBJECT* object) {
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, src, object);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, src, object);
|
||||||
if (std::find(vector.begin(), vector.end(), object) == vector.end()) {
|
if (std::find(vector.begin(), vector.end(), object) == vector.end()) {
|
||||||
TINT_ICE(Clone, Diagnostics())
|
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
|
/// @param object a pointer to the object in #dst that will be inserted at the
|
||||||
/// front of the vector
|
/// front of the vector
|
||||||
/// @returns this CloneContext so calls can be chained
|
/// @returns this CloneContext so calls can be chained
|
||||||
template <typename T, typename OBJECT>
|
template <typename T, typename A, typename OBJECT>
|
||||||
CloneContext& InsertFront(const std::vector<T>& vector, OBJECT* object) {
|
CloneContext& InsertFront(const std::vector<T, A>& vector, OBJECT* object) {
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, dst, object);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, dst, object);
|
||||||
auto& transforms = list_transforms_[&vector];
|
auto& transforms = list_transforms_[&vector];
|
||||||
auto& list = transforms.insert_front_;
|
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
|
/// @param object a pointer to the object in #dst that will be inserted at the
|
||||||
/// end of the vector
|
/// end of the vector
|
||||||
/// @returns this CloneContext so calls can be chained
|
/// @returns this CloneContext so calls can be chained
|
||||||
template <typename T, typename OBJECT>
|
template <typename T, typename A, typename OBJECT>
|
||||||
CloneContext& InsertBack(const std::vector<T>& vector, OBJECT* object) {
|
CloneContext& InsertBack(const std::vector<T, A>& vector, OBJECT* object) {
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, dst, object);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, dst, object);
|
||||||
auto& transforms = list_transforms_[&vector];
|
auto& transforms = list_transforms_[&vector];
|
||||||
auto& list = transforms.insert_back_;
|
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
|
/// @param object a pointer to the object in #dst that will be inserted before
|
||||||
/// any occurrence of the clone of `before`
|
/// any occurrence of the clone of `before`
|
||||||
/// @returns this CloneContext so calls can be chained
|
/// @returns this CloneContext so calls can be chained
|
||||||
template <typename T, typename BEFORE, typename OBJECT>
|
template <typename T, typename A, typename BEFORE, typename OBJECT>
|
||||||
CloneContext& InsertBefore(const std::vector<T>& vector,
|
CloneContext& InsertBefore(const std::vector<T, A>& vector,
|
||||||
const BEFORE* before,
|
const BEFORE* before,
|
||||||
const OBJECT* object) {
|
const OBJECT* object) {
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, src, before);
|
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
|
/// @param object a pointer to the object in #dst that will be inserted after
|
||||||
/// any occurrence of the clone of `after`
|
/// any occurrence of the clone of `after`
|
||||||
/// @returns this CloneContext so calls can be chained
|
/// @returns this CloneContext so calls can be chained
|
||||||
template <typename T, typename AFTER, typename OBJECT>
|
template <typename T, typename A, typename AFTER, typename OBJECT>
|
||||||
CloneContext& InsertAfter(const std::vector<T>& vector,
|
CloneContext& InsertAfter(const std::vector<T, A>& vector,
|
||||||
const AFTER* after,
|
const AFTER* after,
|
||||||
const OBJECT* object) {
|
const OBJECT* object) {
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, src, after);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Clone, src, after);
|
||||||
|
|
Loading…
Reference in New Issue