Click here to Skip to main content
15,885,985 members
Articles / Desktop Programming / WTL

Boost.Range support for ATL/WTL CString

Rate me:
Please Sign up or sign in to vote.
4.12/5 (9 votes)
2 Sep 20052 min read 36.1K   262   11  
Consistent interfaces to CString using Boost.Range.
#pragma once

// Note:
//   verify, whether debugging or not, throws an exception
//   that means exceptional runtime-error.
//   On the other hand, ATLASSERT checks "static" coding mistakes.
//   I think that it was right for ATL designers not to add ATLVERIFY
//   on the initial version, because it must be meaningless
//   to turn on detection of runtime-error that depend on environment
//   only when debugging.
//   Well, api failure is always runtime-error,
//   so you must use verify_api.

#include "../../poost/use.hpp"

namespace tomato {

// See: Error definitions of WinError.h 
template< class BooleanT >
inline void verify(BooleanT expr, HRESULT hr = E_FAIL)
{
#if (_ATL_VER >= 0x0700)
	if (!expr)
		ATL::AtlThrow(hr);
#else
	ATLASSERT(expr);
	poost::use(expr, hr);
#endif
}

template< class BooleanT >
inline void verify_api(BooleanT expr)
{
#if (_ATL_VER >= 0x0700)
	if (!expr)
		ATL::AtlThrowLastWin32();
#else
	ATLASSERT(expr);
	poost::use(expr);
#endif
}

} // namespace tomato

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Japan Japan
I am worried about my poor English...

Comments and Discussions