Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
How to add an instance of a struct to a DynamicVector - Modular
M
Modular
•
3y ago
ct
How to add an instance of a struct to a DynamicVector
A total newbie question
. Example
:
struct Item
:
var name
: StringLiteral
fn
init
(inout self
)
:
self
.name
=
"Unnamed
"
fn main
(
)
:
var dv
= DynamicVector
Item
var it
= Item
(
)
dv
.push
_back
(it
)
Generates error
: invalid call to
'push
_back
'
: method argument
#0 cannot bind generic
!mlirtype to memory
-only type
'Item
'
I don
't understand the error message
.
I cannot find in
https://docs.modular.com/mojo/programming-manual.html
the syntax for this
.
Is there an equivalent to c
+
+
v
e
c
t
o
r
:
:emplace
(
.
.
.
)
?
Modular
Join
This server is the home of the MAX and Mojo community! Join us to chat about all things Modular.
20,199
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Recent Announcements
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
How to store Struct(or string) into DynamicVector
M
Modular / questions
3y ago
Can I have a struct hold a pointer to an another Self instance?
M
Modular / questions
3y ago
How to store PythonObject in DynamicVector?
M
Modular / questions
3y ago
Passing generics to DynamicVector
M
Modular / questions
3y ago