I (eventually) figured out the very obvious solution - just cast the DynamicStruct back to an AnyStruct, (which is clonable), and keep track of the schema elsewhere!
On Friday, 19 November 2021 at 19:39:51 UTC ken...@cloudflare.com wrote: > No, there's no fundamental limitation here. I think we just need an > overload of `clone()` for this that accounts for the subtle API differences > with `DynamicStruct`, e.g. passing the `Schema` in various places. > > -Kenton > > On Thu, Nov 18, 2021 at 6:31 AM Vaci <va...@vaci.org> wrote: > >> Hi, >> >> Should it be possible to use capnp::clone() to copy a DynamicStruct? >> >> This code currently doesn't compile: >> >> #include <capnp/dynamic.h> >> #include <capnp/message.h> >> #include "foo.capnp.h" >> int main() { >> capnp::MallocMessageBuilder mb; >> auto root = mb.initRoot<Foo>(); >> auto a = root.asReader(); >> auto a2 = capnp::clone(a); // succeeds >> auto b = capnp::toDynamic(a); >> auto b2 = capnp::clone(b); // fails >> } >> >> ...but I'm not clear what it is about DynamicStructs that make them less >> copyable? >> >> Cheers, >> Vaci >> >> >> >> -- >> 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 capnproto+...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/capnproto/ce287ada-fee5-4bed-b353-10c438136d40n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/capnproto/ce287ada-fee5-4bed-b353-10c438136d40n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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 capnproto+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/949cbd25-91fa-4ba3-890e-cd6c2221192dn%40googlegroups.com.