boost::lambda start learning
Hi.
I start learning boost.Here is very simple code I can't compile.
typedef std::vector<LPCWSTR> type;
type test;
test[0] = (_T("1"));
test[1] = (_T("2"));
test[2] = (_T("3"));
std::for_each(test.begin(),test.end(), OutputDebugString(_1));
Got compilation error :
------------------
error C2664: 'OutputDebugStringW' : cannot convert parameter 1 from 'boost::lambda::placeholder1_type' to 'LPCWSTR'
------------------
Can anybody point me at mistakes I made in the code?
[591 byte] By [
yurec] at [2007-11-20 11:46:14]

# 1 Re: boost::lambda start learning
The error you got is for a function called OutputDebugStringW but the one you use in your code is OutputDebugString.. apart from that, the name of the function hints to me that it's expecting a string.
What is _1's data type? MSDN says a LPCWSTR is:A 32-bit pointer to a constant null-terminated string of 16-bit Unicode characters.
# 2 Re: boost::lambda start learning
The error you got is for a function called OutputDebugStringW but the one you use in your code is OutputDebugString
Right. Because "OutputDebugString" is actually a macro that is replaced with either 'OutputDebugStringW' or 'OutputDebugStringA' depending on whether the compiler settings are set to unicode or not.
Viggy