问题 #include <utility> template <typename Container> decltype(auto) index(Container &&arr, int n) { return std::forward<Container>(arr)[n]; } Make a function call : #include <vector> index(std::vector {1, 2, 3, 4, 5}, 2) = 0; When function calling finished, the object std::vector {1, 2, 3, 4, 5} will be destroyed, assigning a value to a deallocated address would cause undefined behaviour. But the above code works well and valgrind detected nothing. Maybe the compile helps me make another