7

C++11の新しいエイリアス宣言を使用した次のコード例はVC++11でのコンパイルに失敗し、VS2012の更新1でエラーが発生します。を使用して、Windows7のMinGWでGCC4.7.2を使用して、のぞき見なしでコンパイルおよび実行しg++ -std=c++11 -Wall in.cppます。

これがサポートされていないという兆候は見つかりませんでした。さらに、IntelliSenseはエラーを検出せず、cdptrタイプのツールチップを表示しますtypedef const double *cdptr。私のプロジェクトは、v110プラットフォームツールセットを使用し、C++コードとしてコンパイルするように設定されています。

どうやってマイクロソフトを不当に扱ったのですか?

#include <iostream>

int main()
{
    using cdptr = const double*;

    const double pi = 3.14159;
    cdptr cdp = &pi;

    std::cout << "cdp: " << (*cdp) << std::endl;

    return 0;
}

ビルド出力:

1>------ Build started: Project: AliasDeclTest, Configuration: Debug Win32 ------
1>  AliasDeclTest.cpp
1>f:\aliasdecltest\aliasdecltest.cpp(9): error C2143: syntax error : missing ';' before '='
1>f:\aliasdecltest\aliasdecltest.cpp(9): error C2873: 'cdptr' : symbol cannot be used in a using-declaration
1>f:\aliasdecltest\aliasdecltest.cpp(12): error C2065: 'cdptr' : undeclared identifier
1>f:\aliasdecltest\aliasdecltest.cpp(12): error C2146: syntax error : missing ';' before identifier 'cdp'
1>f:\aliasdecltest\aliasdecltest.cpp(12): error C2065: 'cdp' : undeclared identifier
1>f:\aliasdecltest\aliasdecltest.cpp(14): error C2065: 'cdp' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
4

2 に答える 2

12

MSVC11は、11月のCTPを使用しても、エイリアス宣言の使用を実装していません。

C++11サポートの表はここにあります

于 2013-01-08T23:29:41.350 に答える
6

これに基づくと、VisualStudio2012はまだタイプエイリアスをサポートしていないようです。

于 2013-01-08T23:32:09.107 に答える