Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Are there any debug tools for STL?
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 16th August 14:42
ulrich eckhardt
External User
 
Posts: 1
Default Are there any debug tools for STL?



ostream_iterator<type>(cout, " "));

Wrapped in a small makro/template this is not tedious at all.

Another note: in case you want to use the STLport implementation of the
stdlib, it has a so-called debug-mode that checks for e.g. invalid
iterator dereferenciations.

hth

Uli

--
Questions ?
see C++-FAQ Lite: http://parashift.com/c++-faq-lite/ first !


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
  Reply With Quote


  sponsored links


2 27th August 11:01
ron natalie
External User
 
Posts: 1
Default Are there any debug tools for STL?



If you mean in the debugger, then you'll have to inquire on the system you
are working with. If you mean from within the program...try copy and a stream iterator:
list<int> x;
// put some stuff in x.
copy(x.begin(), x.end(), ostream_iterator<int>(cout, " "));

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
  Reply With Quote
3 22nd September 20:38
yupeng_
External User
 
Posts: 1
Default Are there any debug tools for STL?


What I mean is that how to see the data inside a STL object, such as a
set, from a graphics debugger(eg. xxgdb, ddd). I'm working on a UNIX
machine. I heard from somebody that a "hook" file is useful for
debugger to display the content of the STL objects. But I searched the
WEB, I found nothing about that. Do you have any idea? Thanks!
BTW, my STL is SGI inplementation.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
  Reply With Quote
4 22nd September 20:39
External User
 
Posts: 1
Default Are there any debug tools for STL?


This will give you an extra separator at the end.

--
James Kanze GABI Software mailto:kanze@gabi-soft.fr
Conseils en informatique orientée objet/ http://www.gabi-soft.fr
Beratung in objektorientierter Datenverarbeitung
11 rue de Rambouillet, 78460 Chevreuse, France, +33 (0)1 30 23 45 16

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
  Reply With Quote
5 3rd October 21:23
siemel naran
External User
 
Posts: 1
Default Are there any debug tools for STL?


I guess you have to put the print statements in your code. You can say

#ifndef NDEBUG
container.print();
#endif

--
+++++++++++
Siemel Naran


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
  Reply With Quote
6 3rd October 21:24
andy sawyer
External User
 
Posts: 1
Default Are there any debug tools for STL?


In article <d6652001.0307180209.2d56a946@posting.google.com>,
on 18 Jul 2003 21:07:05 -0400,

Which is why some of us use for_each and a "smart¹" functor to do this
kind of thing:

struct print_it
{
******** print_it( std:stream& out, const char *sep = "" )
: out_( out ), subsequent_( false ), sep_( sep ) {}
template<typename T>
void operator()( const T& output ) const
{
if( subsequent_ )
{
if( sep_ )
out_ << sep_;
}
else
{
subsequent_ = true;
}
out_ << output;
}
private:
mutable bool subsequent_; // Yes, it's a poor name...
std:stream& out_;
const char * const sep_;
}; void fubar() {
std::list<int> x;
// do stuff
std::for_each( x.begin(), x.end(), print_it( std::cout, "," ) );
}

It's kind of ugly that print_it has mutable² state, but them's the
breaks. I'd be interested in hearing of any real-world implementations
of for_each that cause this to break. (I can imagine one, but it's a bit
pathological..)

Regards,
Andy S.
¹ For some value of smart...
² Mutable in both in the English language _and_ the C++ language senses

--
"Light thinks it travels faster than anything but it is wrong. No matter
how fast light travels it finds the darkness has always got there first,
and is waiting for it." -- Terry Pratchett, Reaper Man

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666