Appearance
Nth Argument Access
Unlike runtime arrays, template parameter packs cannot be indexed directly. You need to use template metaprogramming techniques to extract specific arguments at compile time.
Ensure that the type of the returned argument is the same as the type of the nth argument in the template parameter pack and preserve constness and value categories.
Write a variadic template function called 'get_nth' that takes an index N as the first template parameter and variadic arguments, then returns the Nth argument (0-indexed). The function should work with any types and preserve value categories. Use template metaprogramming techniques like std::enable_if or constexpr if for bounds checking.
cpp
// TODO: Implement a variadic template function called 'get_nth'
template<size_t N, typename... Args>
decltype(auto) get_nth(Args&&... args) {
// TODO: Implement your get_nth function here
// The function should return the Nth argument (0-indexed)
// Remember to preserve value categories using perfect forwarding
// Add static_assert for bounds checking
static_assert(N < sizeof...(Args), "Index N is out of bounds");
// Your implementation here
}