This repository was archived by the owner on Mar 21, 2024. It is now read-only.
Enable construction of vectors from std::initializer_list#1836
Merged
miscco merged 3 commits intoNVIDIA:mainfrom Feb 21, 2023
Merged
Enable construction of vectors from std::initializer_list#1836miscco merged 3 commits intoNVIDIA:mainfrom
std::initializer_list#1836miscco merged 3 commits intoNVIDIA:mainfrom
Conversation
Collaborator
Author
|
run tests |
Collaborator
Author
|
run tests |
gevtushenko
approved these changes
Dec 5, 2022
Collaborator
gevtushenko
left a comment
There was a problem hiding this comment.
Thanks for the addition! A few optional comments below.
Collaborator
Author
|
run tests |
jrhemstad
reviewed
Dec 6, 2022
Comment on lines
+198
to
+205
| template<typename T, typename Alloc> | ||
| vector_base<T,Alloc> | ||
| ::vector_base(std::initializer_list<T> il) | ||
| :m_storage(), | ||
| m_size(0) | ||
| { | ||
| range_init(il.begin(), il.end()); | ||
| } // end vector_base::vector_base() |
Collaborator
There was a problem hiding this comment.
I'm lazy, so I'm always a fan of delegating to other constructors when possible. In this case, we can delegate to the iterator pair ctor:
thrust/thrust/detail/vector_base.inl
Line 309 in 37a638e
Suggested change
| template<typename T, typename Alloc> | |
| vector_base<T,Alloc> | |
| ::vector_base(std::initializer_list<T> il) | |
| :m_storage(), | |
| m_size(0) | |
| { | |
| range_init(il.begin(), il.end()); | |
| } // end vector_base::vector_base() | |
| template<typename T, typename Alloc> | |
| vector_base<T,Alloc> | |
| ::vector_base(std::initializer_list<T> il) : vector_base(std::cbegin(il), std::cend(il)) {} |
Collaborator
Author
There was a problem hiding this comment.
We did not touch those constructors and we should either move all of them to a consistent pattern or leave them as is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #1835 and enables construction of vectors from an
initializer_listas well as assignment.