Рассмотрим следующий код: < /p>
template
struct Ambiguous_C {
void func(T);
};
struct Ambiguous_F {
template
void func(T);
};
struct Conflicted_F : public Ambiguous_F{
void test (){
func(1);
func(1);
func(1.1f);
func(1.1f);
}
};
struct Conflicted_C : public Ambiguous_C, Ambiguous_C{
void test (){
//func(1); /* Error */
Ambiguous_C::func(1);
//func(1.1f); /* Error */
Ambiguous_C::func(1.1f);
}
};
< /code>
Member 'func' found in multiple base classes of different types
< /code>
This was compiled using clang 20.1.2
I expected the function calls in Conflicted_C::test() to resolve the overloaded function call based on the function signature, just like the code shown in Conflicted_F::test().
Are there additional considerations taken into account with regards to templated classes that I am not aware of?
Is there a way to implement a templated base class/ method, such that the explicit base class Ambiguous_C:: in front of a call to func can be omitted?
I noticed this gives the same error:
void f_func(int);
void f_func(float);
struct Ambiguous_P1 {
void func(int);
};
struct Ambiguous_P2 {
void func(float);
};
struct Conflicted_P : public Ambiguous_P1, Ambiguous_P2{
void test() {
func(1); /* Error */
func(1.1f); /* Error */
f_func(1); /* Works */
f_func(1.1f); /* Works */
}
};
< /code>
But the question remains the same. Why is the resolution of this ambiguous call not possible based on function signature?
Подробнее здесь: https://stackoverflow.com/questions/795 ... orking-whe
Разрешение шаблона в методе с параметром шаблона класса не работает при использовании множественного наследования в базо ⇐ C++
Программы на C++. Форум разработчиков
1743624255
Anonymous
Рассмотрим следующий код: < /p>
template
struct Ambiguous_C {
void func(T);
};
struct Ambiguous_F {
template
void func(T);
};
struct Conflicted_F : public Ambiguous_F{
void test (){
func(1);
func(1);
func(1.1f);
func(1.1f);
}
};
struct Conflicted_C : public Ambiguous_C, Ambiguous_C{
void test (){
//func(1); /* Error */
Ambiguous_C::func(1);
//func(1.1f); /* Error */
Ambiguous_C::func(1.1f);
}
};
< /code>
Member 'func' found in multiple base classes of different types
< /code>
This was compiled using clang 20.1.2
I expected the function calls in Conflicted_C::test() to resolve the overloaded function call based on the function signature, just like the code shown in Conflicted_F::test().
Are there additional considerations taken into account with regards to templated classes that I am not aware of?
Is there a way to implement a templated base class/ method, such that the explicit base class Ambiguous_C:: in front of a call to func can be omitted?
I noticed this gives the same error:
void f_func(int);
void f_func(float);
struct Ambiguous_P1 {
void func(int);
};
struct Ambiguous_P2 {
void func(float);
};
struct Conflicted_P : public Ambiguous_P1, Ambiguous_P2{
void test() {
func(1); /* Error */
func(1.1f); /* Error */
f_func(1); /* Works */
f_func(1.1f); /* Works */
}
};
< /code>
But the question remains the same. Why is the resolution of this ambiguous call not possible based on function signature?
Подробнее здесь: [url]https://stackoverflow.com/questions/79548142/template-resolution-in-method-with-a-class-template-parameter-is-not-working-whe[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия