STL 를 사용하다보면 어려운 점 중에 하나가 그 내용을 확인하기가 쉽지 않다는 점입니다. 배열을 사용하면 디버그 watch 창에 그 내용물이 보기 쉽게 표시되는데 배열의 STL 대응인 std::vector 를 사용하면 무슨 내용이 vector 저장되어 있는지 디버깅 시 확인하기가 쉽지 않습니다. 다음과 같이 watch 창에 입력하면 std::vector 의 내용을 확인할 수 있습니다.
/* testWatch.cpp : Defines the entry point for the console application. */
#include "stdafx.h"
#include <vector>
#include <string>
struct Student
{
std::string name;
int id;
Student(const std::string & _name, const int & _id) : name(_name), id(_id) { }
};
int main(int argc, char* argv[])
{
std::vector<Student> rgStudent;
rgStudent.push_back(Student("Jae", 1));
rgStudent.push_back(Student("Mina", 2));
printf("Hello World!\n");
return 0;
}
/* testWatch.cpp : Defines the entry point for the console application. */
#include "stdafx.h"
#include <vector>
#include <string>
struct Student
{
std::string name;
int id;
Student(const std::string & _name, const int & _id) : name(_name), id(_id) { }
};
int main(int argc, char* argv[])
{
std::vector<Student> rgStudent;
rgStudent.push_back(Student("Jae", 1));
rgStudent.push_back(Student("Mina", 2));
printf("Hello World!\n");
return 0;
}
/* testWatch.cpp : Defines the entry point for the console application. */ #include "stdafx.h" #include <vector> #include <string> struct Student { std::string name; int id; Student(const std::string & _name, const int & _id) : name(_name), id(_id) { } }; int main(int argc, char* argv[]) { std::vector<Student> rgStudent; rgStudent.push_back(Student("Jae", 1)); rgStudent.push_back(Student("Mina", 2)); printf("Hello World!\n"); return 0; }
a) VC6 내장 STL
” rgStudent.size() ” 를 watch 창에 입력하면 벡터의 크기를 알 수 있습니다..
watch 창의 다음칸에 ” rgStudent._First,2 ” 를 입력하면 (2는 바로 위에서 구한 벡터의 크기) rgStudent 의 내용을 쉽게 확인할 수 있습니다.


b) STLPort 4.6.2
“rgStudent.size()” 를 watch 창에 입력하면 벡터의 크기를 알 수 있습니다.
watch 창의 다음칸에 ” rgStudent._M_start,2 ” 를 입력하면 (2는 바로 위에서 구한 벡터의 크기) rgStudent 의 내용을 쉽게 확인할 수 있습니다.

