Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-09-29 05:30:01


Jonathan Turkanis wrote:

>> template<class>
>> figure_out_name_offset
>> {
>> figure_out_name_offset operator&(nvp& p)
>> {
>> if (p.name() == "name")
>> {
>> m_address = &p.value()
>> }
>> }
>> std::string* m_address;
>> };
>> Person p;
>> figure_out_name_offset f;
>> p.serialize(f);
>> unsigned offset = (int)f.m_address - (int)&p;
>
> Does this force the class to represent it's fields as strings?

The above code -- yes, but I've used std::string for simplicity. I think
it's possible to modify the example in such a way that you won't store an
address of a variable but a formatter*, created from using address of
object, address of &p.value() and depending on type of p.value()

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk