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 <v...@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+unsubscr...@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/CAJouXQkDJ9sDeL_u9YVZxpyNbO1xMeZc%3DSqRT23jGi8hYLtUcg%40mail.gmail.com.

Reply via email to