相关疑难解决方法(0)

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
};
Run Code Online (Sandbox Code Playgroud)

问题是:在C++ 0x中是1.和2.允许和可能(甚至是特定的)?

c++ c++11

8
推荐指数
2
解决办法
1677
查看次数

标签 统计

c++ ×1

c++11 ×1