Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterized constructors for StdVector #385

Merged
merged 7 commits into from
Oct 24, 2023

Conversation

omus
Copy link
Contributor

@omus omus commented Oct 24, 2023

Fixes #367. With this PR the StdVector constructors now support specifying the element type of the vector. Additionally, I've refactored the code to be more inlined with how Vector behaves and have added a more extensive test suite.

Example of the new behaviour of this PR using the examples from #367:

julia> StdVector{StdString}()
0-element CxxWrap.StdLib.StdVectorAllocated{StdString}

julia> StdVector(StdString[])
0-element CxxWrap.StdLib.StdVectorAllocated{StdString}

julia> StdVector(StdString["hello"])
1-element CxxWrap.StdLib.StdVectorAllocated{StdString}:
 "hello"

julia> StdVector{StdString}(StdString["hello"])
1-element CxxWrap.StdLib.StdVectorAllocated{StdString}:
 "hello"

test/stdlib.jl Outdated Show resolved Hide resolved
test/stdlib.jl Outdated Show resolved Hide resolved
@barche
Copy link
Collaborator

barche commented Oct 24, 2023

This looks good to me, so if it's ready for you I can merge it.

@omus
Copy link
Contributor Author

omus commented Oct 24, 2023

Ready to merge. Thanks!

@barche barche merged commit 05548c7 into JuliaInterop:main Oct 24, 2023
@omus omus deleted the cv/stdvector-param branch October 24, 2023 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StdVector loses type information if given empty vector
2 participants