2012-03-31 9 views
0

私は、Calum Grant http://calumgrant.net/units/のC++ Unitsライブラリを使用して、長さまたは速度を表す値を管理しています。C++ユニットを使用した場合の "incomplete type" :: compose

このライブラリで指定されていないユニットが必要です。これは1分あたりのフィートです。

typedef units::compose< units::units::m, units::pow<units::units::s, -1> > meters_per_second;

をが、この例では動作しません:http://calumgrant.net/units/units.htmlによると、あなたは、このように新しいユニットを作ることができます。私は

typedef units::compose< units::units::foot, units::pow<units::units::minute, -1> > 
feet_per_minute; 
feet_per_minute vertical_speed(12); 

を指定した場合、私は(Mac上でGCC 4.2.1を使用して)以下のコンパイルエラーを取得

error: variable 'feet_per_minute vertical_speed' has initializer but incomplete type 

と、このエラー欠けている何を打ち鳴らす3

error: implicit instantiation of undefined template 'units::compose<units::scale<units::scale<units::scale<units::units::m, 100, 1>, 100, 254>, 1, 12>, units::pow<units::scale<units::units::s, 1, 60>, -1, 1> >' 

でコンパイルするとき?

+0

フィート?真剣に? –

答えて

1

まあ、問題が見つかりました。 「単位」が存在し、それらの単位の「価値」が存在する。正しい定義は次のとおりです。

namespace units { 

namespace units { 
    typedef compose< foot, pow<minute, -1> > fpm; 
} 

namespace values { 
    typedef value<double, units::fpm> fpm; 
} 

} 
0

フィート/秒を試してください。それが再起動したかどうか確認してください。

関連する問題