I've got a loop in my code that uses std::basic_string<HANDLE>
, and then waits on it like this:
DWORD dwWaitResult = WaitForMultipleObjects((DWORD)handles.size(),
handles.data(),
FALSE, POLL_INTERVAL_MS);
It works fine, but when I turn on /W4 and /analyze, Visual C++ 2008 warns with the following (cut down and wrapped for brevity):
iosfwd(266) : warning C6001: Using uninitialized memory '*_First'
iosfwd(262) : while compiling class template member function
'HANDLE *std::char_traits<_Elem>::assign(_Elem *,size_t,_Elem)'
with [ _Elem=HANDLE ]
xstring(2155) : see reference to class template instantiation
'std::char_traits<_Elem>' being compiled
with [ _Elem=HANDLE ]
xstring(2148) : while compiling class template member function
'void std::basic_string<_Elem>::_Tidy(bool,unsigned int)'
with [ _Elem=HANDLE ]
.\MyCode.cpp(231) : see reference to class template instantiation
'std::basic_string<_Elem>' being compiled
with [ _Elem=HANDLE ]
iosfwd(222) : warning C6001: Using uninitialized memory '*_First1'
iosfwd(216) : while compiling class template member function
'HANDLE *std::char_traits<_Elem>::_Copy_s
(_Elem *,size_t,const _Elem *,size_t)'
with [ _Elem=HANDLE ]
Questions:
- Is it legal to use std::basic_string with something that's not a simple character type (i.e.
char
orwchar_t
)? - If it is, what should I do to get rid of these warnings? Answering
#pragma warning(disable)
needs justification. - If it's not, why not? And what should I use instead?
Extra credit will be given for bearing in mind that Boost is out, and we're restricted to the STL implementation in Visual C++ 2008; the Visual C++ bits of TR1 are allowed.