Оператор космического корабля с шаблоном варидового классаC++

Программы на C++. Форум разработчиков
Anonymous
Оператор космического корабля с шаблоном варидового класса

Сообщение Anonymous »

У меня есть точка класса , который представляет собой шаблон вариального класса, который имеет конструктор, который принимает вариационные аргументы, что означает, что компилятор поддерживает иметь конструкторы Point с различным количеством аргументов:

#include
#include

using namespace std;

template
class Point
{
std::tuple args;

public:
Point(Args... a) : args(a...) {}
auto operator(const Point&) const = default;
};

int main()
{
std::cout
Point p1(1, 2);
Point p2(1, 2, 3);
Point p3(1, 2, 3, 4).
< /code>
Почему я вижу следующие ошибки (ы)?main.cpp: In function ‘int main()’:
main.cpp:29:22: error: no match for ‘operator>=’ (operand types are ‘Point’ and ‘Point’)
29 | std::cout = p2);
| ~~ ^~ ~~
| | |
| | Point
| Point
main.cpp:20:10: note: candidate: ‘auto Point::operator(const Point&) const [with Args = {int, int, int, int}]’ (reversed)
20 | auto operator(const Point&) const = default;
| ^~~~~~~~
main.cpp:20:22: note: no known conversion for argument 1 from ‘Point’ to ‘const Point&’
20 | auto operator(const Point&) const = default;
| ^~~~~~~~~~~~
main.cpp:20:10: note: candidate: ‘auto Point::operator(const Point&) const [with Args = {int, int, int}]’ (rewritten)
20 | auto operator(const Point&) const = default;
| ^~~~~~~~
main.cpp:20:22: note: no known conversion for argument 1 from ‘Point’ to ‘const Point&’
20 | auto operator(const Point&) const = default;
| ^~~~~~~~~~~~
< /code>
может кто -нибудь помочь мне понять причину этих ошибок? Если да, как я могу это исправить?


Подробнее здесь: https://stackoverflow.com/questions/796 ... s-template

Вернуться в «C++»