Jump to content
  • Advertisement
mark_braga

C++ Is it possible to get STL vector like debugging features for a non STL vector class

This topic is 404 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have always been confused about how std::vector class gets the debugging info. You get a nice list of all the elements in the vector. Whereas, for non-stl vector classes which I have written or used, all you get to see is the first element(begin) and the last element (end) which is just garbage memory.

We don't use any STL code in our engine for obvious reasons but sometimes it's nice to view the contents inside the vector :)

Does Visual studio have some special logic to show all elements of the std::vector in the debug view?

 

Share this post


Link to post
Share on other sites
Advertisement

In Visual Studio you could also use the "autoexp.dat" file in

%VSINSTALLDIR%\Common7\Packages\Debugger\autoexp.dat

for VS2010 and previous (I do not know if this works from 2012 upwards) and write something like this into the file

;------------------------------------------------------------------------------
;  Drough::Vector from <Vector.h>
;------------------------------------------------------------------------------
; vector is previewed with "[<size>](<elements>)".
; It has [size] and [capacity] children, followed by its elements.
; The other containers follow its example.
Drough::Vector<*>{
	preview (
		#(
			"[",
			$e.elementCount,
			"](",
			#array(
				expr: $e.data[$i],
				size: $e.elementCount
			),
			")"
		)
	)

	children (
		#(
			#([size] : $e.elementCount),
			#([capacity] : $e.arraySize),
			#array(
				expr: $e.data[$i],
				size: $e.elementCount
			)
		)
	)
}

 

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!