Код: Выделить всё
#include
#include
template
void f1(std::span param)
{}
template
void f2(const T* param)
{}
int main()
{
std::vector v{1,2,3};
std::span s{v};
// f1(s); // Uncommenting this line causes a compilation error: cannot deduce a type for 'T' that would make 'const T' equal 'int'
int x = 10;
int* px = &x;
const int* z = px;
f2(px); // Works fine
f2(z); // Works fine
}
Почему эта ошибка возникает с std::span, но не с указателями ?
Подробнее здесь: https://stackoverflow.com/questions/791 ... dspan-in-c
Мобильная версия