I am trying to get a simple example to work to understand how to use std::enable_if, here is the problem:
I am reading the textbook C++ Templates The Complete Guide by David Vandevoorde, Nicolai M.Josuttis, Chapter 7, Section 4.
This chapter mentions: "You can use type traits to detect whether an array (or a pointer) was passed", and its following code:
template<typename T,
std::enable_if_t<std::is_array_v<T>>>
void foo(T&& arg1, T&& arg2)
{
}
My question is, how should the above code be called and used? for example, I tried:
int x[] = {1, 2, 3};
int y[] = {1, 2, 3, 4, 5};
foo(x, y);
but didn't compile, i couldn't find similar usage online, can someone please give me some hints or code guidance on how to use above code?