VC++10 Beta 1の今さら気づいたC++0x機能

発表されてなかったので試してもいなかったのですが、
VC++10では戻り値の型を後置する関数宣言構文が使えるようです。
(autoと->のあたりに赤線引かれるけど)


あと、decltype( ( v ) )も使えました。

#include <vector>
#include <type_traits>

using namespace std;

// 関数の戻り値の型(vector<int>)を後置
auto foo() -> vector<int>
{
    return vector<int>();
}

int main()
{
    vector<int> v = foo();

    // decltype(v)はvector<int>で、decltype((v))はvector<int>&
    static_assert(is_same<decltype(v),   vector<int>>::value,  "not same"); // OK
    static_assert(is_same<decltype((v)), vector<int>&>::value, "not same"); // OK
}