2012-05-01 12 views
8

Visual Studio 2010のtr1機能の使い方を教えてください。もっと具体的には、std :: tr1 ::関数が必要です。私は#include <functional>は罰金含んでいるが、不足していると報告し#include <tr1/functional>含めてみましたが、私は、この設定した場合:tr1をVisual Studio 2010(tr1 :: function)で使用する方法は?

std::tr1::function<void(void)> callback; 

を私が取得:私はブーストを使用している場合は、それがこのプロジェクトのために正常に動作しますが、

1>d:\marmalade\projects\core\src\button.h(21): error C3083: 'tr1': the symbol to the left of a '::' must be a type 
1>d:\marmalade\projects\core\src\button.h(21): error C2039: 'function' : is not a member of '_STL' 
1>d:\marmalade\projects\core\src\button.h(21): error C2143: syntax error : missing ';' before '<' 
1>d:\marmalade\projects\core\src\button.h(21): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>d:\marmalade\projects\core\src\button.h(21): error C2238: unexpected token(s) preceding ';' 

特定のフレームワークを使用しているため、Visual Studio tr1バージョンが必要です。

としては、提案TR1をスキップし、それでも同じ結果を返します。デフォルトでは有効になってC++ 11と

std::function<void(void)> callback; 

1>d:\marmalade\projects\core\src\button.h(20): error C2039: 'function' : is not a member of '_STL' 
1>d:\marmalade\projects\core\src\button.h(20): error C2143: syntax error : missing ';' before '<' 
1>d:\marmalade\projects\core\src\button.h(20): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>d:\marmalade\projects\core\src\button.h(20): error C2238: unexpected token(s) preceding ';' 
+4

tr1は、[技術レポート1](http://en.wikipedia.org/wiki/C%2B%2B_Technical_Report_1)の略で、C++標準への追加提案のリストです。提案が受け入れられると、 'tr1'指定は廃止されました。 –

+0

あなたは ''を含めましたか? –

+0

はい、私はそれを含めました。 – Speed

答えて

8

あなたのコメントとthis pageに基づいて、私はマーマレードにそれ自身のSTL実装が付属していると思います。 This pageは2005年にリリースされたTR1をサポートしていないSTLPortのバージョンを使用していることを確認します。あなたのオプションは以下のとおりです。

1)のコピー/それらを自分
2の書き込み)
3)Download a newer version of STLPortずにいます。過去2年間に更新されたようではないので、C++ 11ではなく、functionalと言及していますが、stdまたはstd::tr1名前空間にあるかどうかは不明です。ただし、これはマーマレードでは機能しない可能性がありますので、バックアップを作成してください。

+1

私はそれがちょうどバンドルされていると思います – ildjarn

+0

実際には、それは恐ろしいです:( – Speed

+2

@スピード:STLPortの新しいバージョン_Mayまたは可能かもしれない、答えが更新されました。あなたに助けにならないでください –

2

のVisual Studio 2010隻の船を(あるいは、少なくとも何が実現されます)。 std::function<void(void)>を使用する必要があります。

完全な表see hereについては、

脇に:あなたは今日TR1から何も使用しないでください。それは新しい標準に統合されました。

+0

それにもかかわらず、私はまだまったく同じエラーが出る。 'std :: function コールバック;' 'エラーC2039: 'function': '_STL'のメンバーではありません。 – Speed

+1

@Speedこれは非常に不審なものです。奇妙な'定義 'のためにgrep。 – pmr

関連する問題