У меня есть точка класса , который представляет собой шаблон вариального класса, который имеет конструктор, который принимает вариационные аргументы, что означает, что компилятор поддерживает иметь конструкторы 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++
Программы на C++. Форум разработчиков
-
Anonymous
1751485879
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>
может кто -нибудь помочь мне понять причину этих ошибок? Если да, как я могу это исправить?
Подробнее здесь: [url]https://stackoverflow.com/questions/79687027/spaceship-operator-with-variadic-class-template[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия