Great work on capnp! I'm getting a really smooth ride writing code that 
uses it.   

A question - is there any way to truncate pre-allocated ::capnp::List?   I 
don't mind, that it would leave empty space in the message at the end of 
the list.
Along the lines:

...
myList     @0 :    List(myType)
...

// preallocate
auto myList = builder.initMyList(max_count);
// set count elements
// ...
// 
myList.truncateToSize(count)






I understand that there is an approach of creating an intermediate list, 
along these lines:

capnp::Orphanage orphanage;
std::vector<capnp::Orphan<MyType>> orphans;

 
auto my = orphanage.newOrphan<MyType>();

// Set fields of my
// ...

orphans.push_back(kj::mv(o));

myList.initOp(orphans.size());
int i=0;for(auto it = orphans.begin(); it != ops.end(); ++it, ++i)
   sr.getOp().adoptWithCaveats(i, std::move(*it));



But what I want, seems to be a lot simpler, doesn't need extra copy, etc. 
Just adjust the size field, to truncate the list!


Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to