Я экспериментирует с концепциями C ++. Пытался устранение устранения шаблона «с использованием» по предложению, используя концепцию. Вот упрощенный образец: < /p>
#include
namespace A {
template
class Array
{
public:
typedef double ElementType;
Array() {}
ElementType *data() { return nullptr; }
};
template
concept bool Engine =
requires(E e) { {e.data()} -> std::same_as; };
template
requires Engine
class Container
{
public:
Container() {};
};
} // namespace A
namespace B {
template
using Container = A::Container;
} // namespace B
int main()
{
using namespace A;
using namespace B;
Container d;
return 0;
}
< /code>
Это дает следующую ошибку: < /p>
cio.cc: In function 'int main()':
cio.cc:40:3: error: reference to 'Container' is ambiguous
Container d;
^~~~~~~~~
cio.cc:20:7: note: candidates are: 'template requires Engine class A::Container'
class Container
^~~~~~~~~
cio.cc:31:44: note: 'template using Container = A::Container'
using Container = A::Container;
^
cio.cc:40:13: error: expected primary-expression before 'double'
Container d;
< /code>
Так почему же контейнер считается кандидатом на контейнер? Двойной не выполняет концепции. Где я ошибаюсь?
Подробнее здесь: https://stackoverflow.com/questions/544 ... code-sampl