← Back to team overview

zorba-coders team mailing list archive

Re: [Merge] lp:~zorba-coders/zorba/feature-mem_size into lp:zorba

 

On Jan 10, 2013, at 1:56 PM, Markos Zaharioudakis <markos_za@xxxxxxxxx> wrote:

> Here is the 1st problem: inside mem_sizeof(const XmlNode& t), sizeof(T) (or sizeof(t)) should return 52 if t is actually an ElementNode. Of course, this is not possible since sizeof(T) is computed statically (i.e., at compile time).

Oh.  I get it now.  That's a serious problem.  One solution I can think of is to have size_traits<T> have another member function... something like static_sizeof(T const&).  Unfortunately the only way that can work is if every class in a class hierarchy implements a virtual member function static_size() whose implementation is ALWAYS:

	size_t static_size() const {
	  return sizeof( *this );
	}

As for why the template trick doesn't work, I don't know yet.  Perhaps it's because XmlNode doesn't implement its own alloc_size() but instead inherits it from Item (though I could have sworn I tested this and it worked).

- Paul


-- 
https://code.launchpad.net/~zorba-coders/zorba/feature-mem_size/+merge/114764
Your team Zorba Coders is subscribed to branch lp:zorba.


References