Jump to content
  • Advertisement
mark_braga

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!