我瞭解到,在這樣 auto var = expr;
基本上宣告使用自動變量是喜歡拍照的expr類型和剝離&/& & -references,並從它的所有頂級常量性和volatileness。這是否意味着上述行是正好等同於以下內容? std::remove_cv<std::remove_ref<decltype(expr)>::type>::type var = expr;
考慮下面的代碼: template <class Crtp>
struct Base
{
const float& get(const short int i) const {return std::get<0>(tuple);}
const double& get(const int i) const {return std::get<1>(tuple);}
c
下面的代碼工作爲:目標,左聯和操作:sum(1,2,3,4); 但是,它不會正確的sum(1,2,3,4,5)或sum(1,2,3,4,5,...)工作。任何超過4個參數給出了錯誤: error: no matching function for call to sum(int, int, int, int, int) ================================= templ
考慮following code: struct test {
auto func() -> decltype(data) {} // ERROR
int data;
};
int main() {
test t;
t.func();
}
它提供了以下錯誤: main.cpp:2:29: error: 'data' was not decla