Я изучаю руководства по дедукции в C++. Затем я написал следующий код, который компилируется с помощью gcc и msvc, но отклоняется clang. Демо
Я хочу знать, какой компилятор находится здесь.
#include
#include
#include
struct Coord
{
int x, y;
};
template
class CoordArray
{
public:
CoordArray(const Coord(&ref)[N])
{}
};
template CoordArray() -> CoordArray;
CoordArray myCoordArray{{{2, 1}, {4, 1}, {6, 1}}}; //clang rejects but gcc and msvc accepts
CoordArray myCoordArray2{{{2, 1}, {4, 1}, {6, 1}}}; //clang rejects but gcc and msvc accepts
Кланг говорит:
:17:24: error: deduction guide template contains template parameters that cannot be deduced
17 | template CoordArray() -> CoordArray;
| ^
:17:14: note: non-deducible template parameter 'D'
17 | template CoordArray() -> CoordArray;
| ^
:17:21: note: non-deducible template parameter 'N'
17 | template CoordArray() -> CoordArray;
|
Подробнее здесь: https://stackoverflow.com/questions/781 ... d-by-clang