looking something identical offsetof() non-pod types


i'm looking proceed obtain offsets information members c++ category non-pod nature.



here's why:



i'd store information format, seems many matched kind component (numerical chronicle output), nonetheless maybe rather c-oriented library. i wish by c++ interface, need me announce storage forms (following support (section 4.3.2.1.1)):



class instance { 
public:
double member_a;
int member_b;
} //class example

h5::comptype func_that_creates_example_comptype() {
h5::comptype ct;
ct.insertmember("a", hoffset(example, member_a), h5::predtype::native_double);
ct.insertmember("b", hoffset(example, member_b), h5::predtype::native_int);
relapse ct;
} //func_that_creates_example_comptype


where hoffset hdf-specific macro uses offsetof.



the problem course, shortly example-class becomes small bit some-more featureful, longer pod-type, controlling offsetof give capricious results.



the wholly workaround i cruise initial trade information i wish store easier struct, following pass hdf. does however secure information copying, accurately hdf perplexing prevaricate (and since have comptype enables library strech your objects save information file).



so i anticipating you'd have improved ideas. ideally i'd looking unstable workaround problem, nonetheless brief give me an thought works x86 x86_64 gcc i'd already immensely grateful.



----- appended later: -----



greg hewgill suggested next store information rudimentary struct, following build tangible category inheriting that. hdf specifically, i cruise competence many work. some-more elaborate use unfolding above:



class base_pod {
public:
double member_a;
int member_b;
}; //class base_pod

class derived_non_pod : private base_pod {
public:
//the following slight wholly practical illustrate problem
practical double get_member_a() {return member_a; }
}; //class derived_non_pod

class that_uses_derived_non_pod {
public:
vacant whatever();
private:
derived_non_pod member_c;
}; //class that_uses_derived_non_pod


now, we're storing instances category that_uses_derived_non_pod, can't news the memory plans base_pod member_c. offsets wrong since derived_non_pod adds musty things (like practical duty table, i guess?).



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members