この質問は、(何らかの理由で)このタイプのテンプレートを使用したくないことが明らかです。C++ 0xは関数シグネチャでdecltype()を使用できますか?
class Product
{
public:
Product(decltype(mPrice) price_, decltype(mLabel) label_) // 1.
: mPrice(price_), mLabel(label_)
{}
decltype(mPrice) price() const {return mPrice;} // 2.
decltype(mLabel) label() const {return mLabel;} // 2.
private:
float mPrice ; // type might later be changed to more acurate floating point abstraction
std::string mLabel; // type might later be changed by a special localization-oriented string
};
質問です:C++ 0xの中で1.と2.許可され、可能な(あるいは具体的に定義され)ていますか?
クール!それは標準的な動作かgcc実装の動作だけですか? – Klaim
私が知る限り、これは標準的な動作です。 – TonyK
@Klaim標準では、「関数declarator-idの前に指定するのがより複雑な型に対しては、指定された型の戻り値が最も有用です」は、関数が有効で後続の戻り値が(もし必要ならlamdas) – MerickOWA