Movin’ Out

(With apologies to Billy Joel.) This is it: Hopefully the last time I move this blog for a while. I’ve moved over to a planned-to-be long-term blog home over at PluralSight. Thanks to Don for prodding, Fritz for hosting, and retroactive thanks to all the folks at MSDN and GDN for hosting my initial blog…


Simulating try/finally in plain C++ (without the C++/CLI extensions)

Dan wrote: I think this is close enough to try/finally in C++: Resource* pRes = new Resource; try {   // use the allocated resource somehow } catch (…) {   delete pRes;   throw; } First, note that this code as written doesn’t do “finally,” because the idea behind a finally block is that…


Downloading the Express beta compiler

Mark wrote: I have downloaded the Visual C++ Express and have been trying out simple programs. I have to say C++/CLI is amazingly simple and elegant compared to MC++. You guys rock!!! That reminds me to announce (belatedly): Try out the free Express compiler and play around with the new syntax. Make sure you also…


C++/CLI timeline and one-line description

Ioannis Vranos wrote: There is an upcoming C++/CLI standard (currently draft, official  document expected in December 2004) Just a note, we now expect to complete work on the C++/CLI standard in March and have it approved by Ecma in June. We wanted the extra time to complete and polish the C++/CLI spec, but another reason…


finally + destructors = best of both worlds

On comp.lang.c++.moderated, “Howard” <> wrote: You know how we use try { } catch() {} in C++?  Well, both Delphi and C# (which was developed with the aid of one of Delphi’s main original developers) have another construct, which is “try {} finally {}”.  The idea is that no matter what else takes place, no…


An update to the C++/CLI draft

An interim updated snapshot of the C++/CLI draft standard is now available: C++/CLI Language Specification (Working Draft 1.5, June 2004) Related links: C++/CLI home page on MSDN Visual C++ home page on MSDN


A new article on C++/CLI

Kenny Kerr announced a cool article he wrote about C++/CLI on MSDN: C++/CLI: The Most Powerful Language for .NET Programming


C++ RAII compared with Java Dispose pattern

Earlier today I wrote that: “The C++ destructor model is exactly the same as the Dispose and using patterns, except that it is far easier to use and a direct language feature and correct by default, instead of a coding pattern that is off by default and causing correctness or performance problems when it is…


More on % (managed reference)

Keith Duggar asked: Ok, I’m missing a basic point here. So, out of curiousity: 1) Is there any overhead associated with using ‘T%’ in place of ‘T&’? No. 2) Are there things that can be done with ‘T&’ that cannot be done with ‘T%’ Yes: A % can only exist on the stack (a CLI…


Using % and &

This post brings together three related questions and answers posted recently on comp.lang.c++.moderated. They all have to do with the relationship between % (tracking reference) and & (unmanaged reference). First, Dietmar Kuehl asked about this C++/CLI code: template <typename T> void f(T&) {} int main() {  int^ ptr = gcnew int(0);  f(*ptr);  // error} The…