This post originated from an RSS feed registered with Java Buzz
by Weiqi Gao.
Original Post: New Language Features Galore
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Just as Java's new language features buzz is dying down (reified generics no longer being mentioned, etc.) the C++0x standards is nearing completion.
In today's OCI internal C++ lunch, Adam Mitz (who apparently needs a more updated homepage) talked about the new C++ language features that may become available in the updated standard. We've covered the new library features in a previous C++ lunch.
Here's some of the more interesting features.
Raw strings
R"$
A string that may contain embedded
new line characters.
$"
Lambdas
<>(int x, int y) -> int {return x + y; }
Closures
std::cout& os = ...;
setCallback(<>(int i) extern(os) { os << i; });
RValue References
A&& r = getA();
Variadic Templates
template <class... Elements> class tuple;
Alternative syntax for typedef
using callback = void (*)(void*, int);
Type inference
auto pi = 3.1415926535;
const auto& v = map["key"];
Concepts
template <LessThanComparable T> class ...;
auto concept LessThanComparable
<typename T> { bool operator<(T, T); };
Range based for loop
for (int i: vector_of_ints) {
std::cout << i;
}
String enums
enum class E : unsigned long lone {A, B, C};
And the quote of the day came when Adam answered the question "is this a hack?" with