"Philippe A. Bouchard" <[EMAIL PROTECTED]> wrote in message b2jlq6$92u$[EMAIL PROTECTED]">news:b2jlq6$92u$[EMAIL PROTECTED]... > David B. Held wrote: > > unsigned Count_; > > char Value_[sizeof(T)]; > > }; > > Another little thing... > > Value_ will have to be aligned just like an object of type T.
;) On my platform, the Count_ variable will ensure this alignment. I don't pretend that this code is particularly portable. Also, my platform doesn't have any alignment requirements anyway. ;) > Wouldn't it be possible to derive TCounted_Record<T> from > TRecord<T>, removing Value_ at the same time? No, I don't want to do that derivation, because sometimes I will only have a record ID to store. If I derive from the actual record type, the c'tor will need to default construct the record, and then I'll have to populate it later, which is wasteful (and expensive, if I never actually need the full record). This way, I can store just the ID. Consider this example: struct TLocation : public Record { std::string Address1_; std::string Address2_; std::string City_; PState State_; std::string MailCode_; }; typedef boost::intrusive_ptr<TCountedRecord<TLocation> > PLocation; struct TEmployee : public TRecord { std::string Name_; std::string SSN_; PLocation Location_; }; typedef boost::intrusive_ptr<TCountedRecord<TEmployee> > PEmployee; std::vector<PEmployee> results; results.push_back(new TCountedRecord<TEmployee>(3242)); results.push_back(new TCountedRecord<TEmployee>(4232)); results.push_back(new TCountedRecord<TEmployee>(7929)); results.push_back(new TCountedRecord<TEmployee>(3459)); Now, like I explained in the serial_ptr post, in my design, the server only returns a list of record id's. That way, if I already have some of the records cached (from previous queries), I don't have to send all the data over the wire again. In that case, I don't want to store an entire default record, because even the default c'tor called many times is going to be slower than the default c'tor for a simple TRecord. Since performing queries can be a frequent operation with large result sets, it's important to avoid unnecessary operations. Dave _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost