Это не будет компилироваться в функции шаблона, но версия без размера работает нормально. Я не могу найти почему? < /P>
#include
#include
#include
#include
//constexpr int get_item(const int i, const std::span arr)
//{
// return arr;
//}
//template
//constexpr T get_item(const int i, const T(&arr)[N])
//{
// return arr;
//}
template
constexpr T get_item(const int i, const std::span arr)
{
return arr;
}
template
constexpr T get_item(const int i, const std::span arr)
{
return arr;
}
int ITEM_CARRAY[]
{
0,
1,
2,
3
};
std::vector ITEM_VECTOR
{
0,
1,
2,
3
};
void main()
{
auto val_carray{ get_item(1, ITEM_CARRAY) };
std::cout
Подробнее здесь: https://stackoverflow.com/questions/797 ... -parameter