[GCC-XML] GccXml and STL

Christopher Lamothe christopherjl at hotmail.com
Tue Feb 21 09:25:20 EST 2012

    Currently I am working on upgrading our system to work with MsDev2010 - our system uses GCC_XML to parse our project in order to get information about the produced DLL.
   That being said I found a few newer versions of GCC_XML some of which had implemented some STL types, for example vector: in the include for "Vc8ex" there is a file that contains the definition of the vector class. For the other classed I created my own definitions however I am concerned that my output will not work as expected see my definition for shared pointer:
template<class _Ty>	struct shared_ptr {};
   GCC_XML has no problem parsing this and my code seems to function correctly. However what about the class size? Will the compiler adjust for the actual size of the class or is there a possibility that my objects body will overlap in the heap?
Chris Lamothe

P.S. Why is my stub so much simpler than auto_ptr? - See below, looks like the whole H file.
template<class _Ty>	class auto_ptr		{	// wrap an object pointer to ensure destructionpublic:	typedef _Ty element_type;
	explicit auto_ptr(_Ty *_Ptr = 0) _THROW0()		: _Myptr(_Ptr)		{	// construct from object pointer		}
	auto_ptr(auto_ptr<_Ty>& _Right) _THROW0()		: _Myptr(_Right.release())		{	// construct by assuming pointer from _Right auto_ptr		}
	auto_ptr(auto_ptr_ref<_Ty> _Right) _THROW0()		{	// construct by assuming pointer from _Right auto_ptr_ref		_Ty **_Pptr = (_Ty **)_Right._Ref;		_Ty *_Ptr = *_Pptr;		*_Pptr = 0;	// release old		_Myptr = _Ptr;	// reset this		}
	template<class _Other>		operator auto_ptr<_Other>() _THROW0()		{	// convert to compatible auto_ptr		return (auto_ptr<_Other>(*this));		}
	template<class _Other>		operator auto_ptr_ref<_Other>() _THROW0()		{	// convert to compatible auto_ptr_ref		_Other *_Testptr = (_Ty *)_Myptr;	// test implicit conversion		auto_ptr_ref<_Other> _Ans(&_Myptr);		return (_Testptr != 0 ? _Ans : _Ans);		}
	template<class _Other>		auto_ptr<_Ty>& operator=(auto_ptr<_Other>& _Right) _THROW0()		{	// assign compatible _Right (assume pointer)		reset(_Right.release());		return (*this);		}
	template<class _Other>		auto_ptr(auto_ptr<_Other>& _Right) _THROW0()		: _Myptr(_Right.release())		{	// construct by assuming pointer from _Right		}
	auto_ptr<_Ty>& operator=(auto_ptr<_Ty>& _Right) _THROW0()		{	// assign compatible _Right (assume pointer)		reset(_Right.release());		return (*this);		}
	auto_ptr<_Ty>& operator=(auto_ptr_ref<_Ty> _Right) _THROW0()		{	// assign compatible _Right._Ref (assume pointer)		_Ty **_Pptr = (_Ty **)_Right._Ref;		_Ty *_Ptr = *_Pptr;		*_Pptr = 0;	// release old		reset(_Ptr);	// set new		return (*this);		}
	~auto_ptr()		{	// destroy the object		delete (_Ty *)_Myptr;		}
	_Ty& operator*() const _THROW0()		{	// return designated value
 #if _HAS_ITERATOR_DEBUGGING		if (_Myptr == 0)			_DEBUG_ERROR("auto_ptr not dereferencable"); #endif /* _HAS_ITERATOR_DEBUGGING */
		return (*(_Ty *)_Myptr);		}
	_Ty *operator->() const _THROW0()		{	// return pointer to class object		return (&**this);		}
	_Ty *get() const _THROW0()		{	// return wrapped pointer		return ((_Ty *)_Myptr);		}
	_Ty *release() _THROW0()		{	// return wrapped pointer and give up ownership		_Ty *_Tmp = (_Ty *)_Myptr;		_Myptr = 0;		return (_Tmp);		}
	void reset(_Ty* _Ptr = 0)		{	// destroy designated object and store new pointer		if (_Ptr != _Myptr)			delete (_Ty *)_Myptr;		_Myptr = _Ptr;		}
private:	const _Ty *_Myptr;	// the wrapped object pointer	};

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/gccxml/attachments/20120221/14e14d82/attachment.html>

More information about the gccxml mailing list