Der Abzugsleitfaden funktioniert in gcc und msvc, wird jedoch von Clang abgelehntC++

Programme in C++. Entwicklerforum
Anonymous
 Der Abzugsleitfaden funktioniert in gcc und msvc, wird jedoch von Clang abgelehnt

Post by Anonymous »

Ich lerne etwas über Deduktionsleitfäden in C++. Dann habe ich den folgenden Code geschrieben, der mit gcc und msvc kompiliert, aber von clang abgelehnt wird. Demo
Ich möchte wissen, welcher Compiler hier richtig ist.

Code: Select all

#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

Clang sagt:

Code: Select all

: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;
|

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post