在我當前的專案(Xilinx Vitis 的硬體加速)中,我試圖包含一個僅使用頭檔案的庫,它使用了幾個 C 2017 功能。然而,賽靈思 Vitis不允許使用 C 2017。現在,由于它是一個僅標頭庫,我嘗試創建它的本地副本,并將所有 C 2017 功能替換為其 C 2014 等效項。然而,代碼中有 4 行如下所示:
using X = typename std::invoke_result_t<Fin, size_t>::first_type;
using Y = typename std::invoke_result_t<Fin, size_t>::second_type;
現在,我理解在 Cppreference 上找到的檔案的方式,我認為重寫這些行的正確方法如下所示:
using X = typename std::result_of_t<Fin>::first_type;
using Y = typename std::result_of_t<Fin>::second_type;
但是,這會在編譯時導致幾個(相同的)錯誤:
/Workspace/PGM-index/include/pgm/piecewise_linear_model.hpp:333:49:錯誤:無效使用不完整型別'class std::result_of<pgm::PGMIndex<K, Epsilon, EpsilonRecursive, Floating>::build( RandomIt, RandomIt, size_t, size_t, std::vector<pgm::PGMIndex<K, Epsilon, EpsilonRecursive, Floating>::Segment>&, std::vector<long unsigned int, std::allocator >&) [with RandomIt = __gnu_cxx::__normal_iterator<const int*, std::vector<int, std::allocator >>; K = 整數;long unsigned int Epsilon = 128; long unsigned int EpsilonRecursive = 4; 浮動=浮動;size_t = long unsigned int]::<lambda(auto:8)> >'
因此,如果有人可以幫助我理解我將如何改寫這些行以完成編譯,我將不勝感激。如果有任何資訊缺失,請告訴我。
uj5u.com熱心網友回復:
to 的單個引數std::result_of_t是(非常誤導1)函式型別。在你的情況下,它會是std::result_of_t<Fin(size_t)>.
- 該函式型別表示一個函式,它接受引數并回傳您正在檢查的可呼叫型別。出于這個原因,它在 C 17 中被棄用并在 C 20 中被洗掉。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/494098.html
上一篇:使用Eigen時出錯:無效使用不完整型別'constclassEigen
下一篇:C 11:如何使用lambda作為型別引數,它需要像std::less/std::greater這樣的“函子型別”?
