https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104255
--- Comment #1 from qingzhe huang <nickhuang99 at hotmail dot com> --- Just a FYI, this version is a bit simplified from this original code. (https://www.godbolt.org/z/n7ajzr46f) because this is an actual meaningful function to reverse a given index_sequence. You can see if trailing return type works, it doesn't need to define the function body so that the template function works exactly like a meta function. template<size_t...Indexes, size_t...Numbers> auto get_reverse_sequence_helper(index_sequence<Indexes...>indexes, index_sequence<Numbers...>numbers) // If this trailing return type is OK, we don't need actually define // function body. ->index_sequence< (getSeqByIndex<Indexes, Numbers...>(numbers))... > { return index_sequence< (getSeqByIndex<Indexes, Numbers...>(numbers))... >{}; }