看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: Win10, Linux, ...) windows 10 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) gcc 4.9.3 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 我是用Rcpp,我一直沒想通為什麼 而且google也看不太懂,自己C++功力沒有很深Orz Rcpp::NumericVector 這個object有下面這個method: inline int sexp_type() const { return TYPEOF( static_cast<const Class&>(*this) ) ; } 我想用sexp_type回傳的int去得到Rcpp::NumericVector的type (double) 但是會出現 // error: 'RTYPE1' cannot appear in a constant-expression 想問我哪裏寫錯了 x是 Rcpp::NumericVector 1. sexp_type const int RTYPE1 = x.sexp_type(); typedef typename Rcpp::traits::storage_type< RTYPE1 >::type type; // error: 'RTYPE1' cannot appear in a constant-expression 2. const int => PASS const int RTYPE2 = 14; typedef typename Rcpp::traits::storage_type< RTYPE2 >::type type; // PASS Rcpp::traits::storage_type在這裡: https://goo.gl/N7Wb82 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.233.49.87 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1489310142.A.AE6.html ※ 編輯: celestialgod (36.233.49.87), 03/12/2017 17:37:01
loveflames: RTYPE1的值不是在compile time得出,是要怎麼套進temp 03/12 19:43
loveflames: late 03/12 19:43