I experiment with c++ concepts. Tried to disambiguate a template 'using' clause by using a concept. Here is a simplified sample:
#include <concepts>namespace A {template <typename T>class Array{ public: typedef double ElementType; Array() {} ElementType *data() { return nullptr; }};template <typename E>concept bool Engine =requires(E e) { {e.data()} -> std::same_as<typename E::ElementType *>; };template <typename E>requires Engine<E>class Container{ public: Container() {};};} // namespace Anamespace B {template <typename T>using Container = A::Container<A::Array<T>>;} // namespace Bint main(){ using namespace A; using namespace B; Container<double> d; return 0;}
This yields the following error:
cio.cc: In function 'int main()':cio.cc:40:3: error: reference to 'Container' is ambiguous Container<double> d; ^~~~~~~~~cio.cc:20:7: note: candidates are: 'template<class E> requires Engine<E> class A::Container' class Container ^~~~~~~~~cio.cc:31:44: note: 'template<class T> using Container = A::Container<A::Array<T> >' using Container = A::Container<A::Array<T>>; ^cio.cc:40:13: error: expected primary-expression before 'double' Container<double> d;
So why is A::Container considered a candidate for Container? double does not fulfil the concepts. Where am I wrong?