Hi Raphael, Lists of structs are a bit awkward. There is no set() method, but there is a setWithCaveats() method, which is mostly the same but can lead to some gotchas. See the comments here:
https://github.com/capnproto/capnproto/blob/677a52ab2412f34028e43400a96a468618b94493/c++/src/capnp/list.h#L276-L285 Also, you don't need the setList() call at the end of your method. The earlier initList() call creates the list in-place, so it is already part of the results structure. The setList() call here will actually create an unnecessary copy of the list, overwriting itself. -Kenton On Sat, Jan 19, 2019 at 8:33 AM <[email protected]> wrote: > here is the error in the compilation > > 26:22: error: no member named 'set' in 'capnp::List<ServiceDescription, > capnp::Kind::STRUCT>::Builder' > list.set(i++, it->second); > > On Saturday, January 19, 2019 at 11:32:45 AM UTC-5, > [email protected] wrote: >> >> Hi, >> >> I have just started looking the C++ package and I am blocked on something >> that should be easy. What I found in this group or in some examples can't >> seem to fix my issue. >> I am with C++ 17 / Capnp 0.7.0 on Mac >> >> My example is a simple interface: >> >> interface MyService { >> >> services @0 () -> (list: List(ServiceDescription)); >> } >> >> When I implement it I try to set the list to like so: >> >> kj::Promise<void> aggregators(AggregatorsContext context) override { >> auto list = context.getResults().initList(serviceMap.size()) ; >> int i=0; >> for (std::map<int,ServiceDescription>::iterator it=serviceMap.begin(); >> it!=serviceMap.end(); ++it) >> list.set(i++, it->second); >> context.getResults().setList(list); >> return kj::READY_NOW; >> } >> >> >> >> But I am getting a compilation error saying that the set member does not >> exist yet even though it is there in the API... >> >> >> I must be doing something too plainly wrong to see ... >> >> >> thanks for any pointer >> >> >> >> -- > 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. > -- 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.
