Static If I Had a Hammer

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
All right, the C++11 Standard is done. Can we go home? Definitely not - progress waits for no one. For all its might, C++11 is not addressing a few basic needs in template programming. For example, youd hate to have to define a new function or indeed a whole new class wherever you need an "if" statement; yet, this is exactly what we do for template code. Also, conditional overloading using the likes of std::enable_if is syntactically bulky and semantically ham-fisted (as is visible with constructors and other special functions). This talk describes a new proposal (joint work with Herb Sutter and Walter Bright): a "static if" construct that works much like "if", just during compilation. Its reminiscent of #if, just done copiously right.

With "static if" a lot of generic code becomes radically simpler, which in turn enables idioms that today are too complex to be usable. This proposal for C++ benefits from a large body of experience within the D programming language. <img src="http://m.webtrends.com/dcs1wotjh10000w0irc493s0e_6x1g/njs.gif?dcssip=channel9.msdn.com&dcsuri=http://channel9.msdn.com/Feeds/RSS&WT.dl=0&WT.sessionid=Session:RSSView:046c6a823d47416ba22e9fd4012bf5e4

View the full article
 
Back
Top