In my current project (Hardware Acceleration with Xilinx Vitis) I'm trying to include a header only Library which uses several C 2017 features. Xilinx Vitis however does not allow C 2017 to be used. Now since it is a header only library I tried to just create a local copy of it and replace all C 2017 Features with their C 2014 Equivalents. There are however 4 Lines in the Code which look like this:
using X = typename std::invoke_result_t<Fin, size_t>::first_type;
using Y = typename std::invoke_result_t<Fin, size_t>::second_type;
Now, the way I understood the documentation found on Cppreference I figured that the correct way to rewrite these lines would look like this:
using X = typename std::result_of_t<Fin>::first_type;
using Y = typename std::result_of_t<Fin>::second_type;
However, this causes several (same) errors while compiling:
/Workspace/PGM-index/include/pgm/piecewise_linear_model.hpp:333:49: error: invalid use of incomplete type ‘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 = int; long unsigned int Epsilon = 128; long unsigned int EpsilonRecursive = 4; Floating = float; size_t = long unsigned int]::<lambda(auto:8)> >’
So if anyone could help me understand how I would have to rephrase those lines to get the compilation to complete, I would be thankful. If there is any Information missing, please let me know.
CodePudding user response:
The single parameter to std::result_of_t
is a (very misleading1) function type. In your case it would be std::result_of_t<Fin(size_t)>
.
- That function type denotes a function that takes the arguments and returns the callable type that you are inspecting. For this reason it was deprecated in C 17 and removed in C 20.