Symphilosophein 狂者進取,狷者有所不為也。
#include <type_traits> template <typename... Ts> using last_type_t = Ts...[sizeof...(Ts) - 1]; template<typename... T> void run(T... t) { decltype(t...[1]) i = 0; // float } int main() { static_assert(std::is_same_v<last_type_t<int>, int>); static_assert(std::is_same_v<last_type_t<bool, char>, char>); static_assert(std::is_same_v<last_type_t<float, int, bool*>, bool*>); struct tmp{}; run(1, 2.0f, tmp{}); }
Note: Only a member of this blog may post a comment.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.