Does using directives not work with concepts? why?
The example below doesn't work and I get a compiler error saying that it expected a type.
#include <concepts>
namespace A::X {
struct BaseA {};
template < typename AType >
concept DerivedFromA = std::derived_from < AType, BaseA >;
}
namespace A {
using DerivedFromA = X::DerivedFromA;
}
I want to be able to access concept DerivedFromA
from namespace A
as DerivedFromA
rather than X::DerivedFromA
Does using directives not work with concepts? why?
Because the way you're employing using
declares a type alias. And concept
s are not type templates.
What you intend to do is to make a name from one namespace available in a different one. That looks like this:
namespace A
{
using X::DerivedFromA;
}
This works on all kinds of names.