Re: Where did OMANIP and IOMANIP go in VS C++ 2003, and what to use instead?
"Bill Davy" <Bill@SynectixLtd.com> wrote in message
news:Oaaa1mi6HHA.5360@TK2MSFTNGP03.phx.gbl
I used to use this in VC6 and it worked:
typedef struct
{
const TCHAR *m_pSeparator, *m_pName;
} SeparatorWithNameT;
IOMANIPdeclare( SeparatorWithNameT );
ostream& fp( ostream& o, SeparatorWithNameT pair );
OMANIP(SeparatorWithNameT) SepWithName( const TCHAR *pSep, const TCHAR
*pName );
But under Microsoft Visual C++ .NET 69462-270-0000007-18335 I get:
h:\Husky\HostPC\Loader\Mark1\Mark1\Utils.hpp(137) : error C2146:
syntax error : missing ';' before identifier 'SepWithName'
Where did OMANIP (and IOMANIP, for that matter) go, and what is the
new solution?
This is how you define your own manipulators:
struct SeparatorWithNameT{
const TCHAR *m_pSeparator, *m_pName;
} SeparatorWithNameT;
basic_ostream<TCHAR>& operator<<(
basic_ostream<TCHAR>& os, const SeparatorWithNameT& sep) {
return os << sep.m_pSeparator << sep.m_pName;
}
SeparatorWithNameT SepWithName(
const TCHAR *pSep, const TCHAR *pName) {
SeparatorWithNameT sep = {pSep, pName};
return sep;
}
cout << "Hello" << SepWithName(", ", "Bill") << endl;
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925