Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Should naked pointers (--cpp_ptr_type naked) work with vectors of tables? #8390

Unanswered
mdrossmiller asked this question in Q&A
Discussion options

Should it be possible to use 'naked' pointers with vectors of tables? Or is this an unreasonable expectation?

Given fbs file like:

table a { b:[byte]; }
table c { d:[a]; }
table f { g:[c]; }
root_type f;

compiled using this command:

flatc --cpp --no-warnings --scoped-enums --gen-object-api --cpp-ptr-type naked --cpp-std C++17 --cpp-static-reflection --reflect-
types --schema --binary f.fbs 

creates a _generated.h file which cannot be compiled. (sample errors follow)

In file included from sample_issue.cpp:2:
f_generated.h: In member function ‘void c::UnPackTo(cT*, const flatbuffers::resolver_function_t*) const’:
f_generated.h:341:167: error: request for member ‘get’ in ‘_o->cT::d.std::vector<aT*>::operator[](((std::vector<aT*>::size_type)_i))’, which is of pointer type ‘__gnu_cxx::__alloc_traits<std::allocator<aT*>, aT*>::value_type’ {aka ‘aT*’} (maybe you meant to use ‘->’ ?)
 341 | { auto _e = d(); if (_e) { _o->d.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->d[_i]) { _e->Get(_i)->UnPackTo(_o->d[_i].get() /*foobar*/, _resolver); } else { _o->d[_i] = (_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->d.resize(0); } }
 | ^~~
f_generated.h: In member function ‘void f::UnPackTo(fT*, const flatbuffers::resolver_function_t*) const’:
f_generated.h:377:167: error: request for member ‘get’ in ‘_o->fT::g.std::vector<cT*>::operator[](((std::vector<cT*>::size_type)_i))’, which is of pointer type ‘__gnu_cxx::__alloc_traits<std::allocator<cT*>, cT*>::value_type’ {aka ‘cT*’} (maybe you meant to use ‘->’ ?)
 377 | { auto _e = g(); if (_e) { _o->g.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { if(_o->g[_i]) { _e->Get(_i)->UnPackTo(_o->g[_i].get() /*foobar*/, _resolver); } else { _o->g[_i] = (_e->Get(_i)->UnPack(_resolver)); }; } } else { _o->g.resize(0); } }
 | 
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /