ローカルの CygWin インストールで g++ コンパイラを使用して PIMPL を実装しようとしてきましたが、g++ 4.3.4 を実行していることが事実である可能性があると考え始めています。完全。
非常にベースラインのコード (MSDN hereから):
my_class.h:
#include <memory>
class my_class {
public:
my_class();
private:
class impl; unique_ptr<impl> pimpl(new impl);
};
my_class.cpp:
#include "my_class.h"
class my_class::impl { int my_int; };
my_class::my_class(): pimpl( new impl ) {};
私はコンパイルしようとしg++ -std=c++0x -o my_class.o my_class.cpp
、最終的には次のようになります。
In file included from my_class.cpp:1:
my_class.h:8: error: ISO C++ forbids declaration of 'unique_ptr' with no type
my_class.h:8: error: invalid use of '::'
my_class.h:8: error: expected ';' before '<' token
my_class.cpp: In constructor 'my_class::my_class()':
my_class.cpp:5: error: class 'my_class' does not have any field named 'pimpl'
を代入するとそれもわかり-std=gnu++0x
ます。
実際、最も単純なファイルでさえコンパイルしようとすると、別の SO 回答から持ち上げられます。
#include <iostream>
#include <memory>
int main() {
std::unique_ptr<int> up( new int( 30 ) );
}
名前空間unique_ptr
にないことが不平を言います。std
gcc c++11 サポート ページにはエントリがありませんが、ネットを見ると、少なくとも4.4 以降unique_ptr
、かなり前から存在しています。
私の質問は、まず、gcc
サポートがunique_ptr
追加されたのはどのバージョンですか?
そして、第二に、コードを間違った方法で使用して、コードに骨の折れる間違いを犯しているだけですか?