This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82247] [concepts] Name deduction in concepts fails depending on the argument type
- From: "Casey at Carter dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 31 Oct 2017 14:35:58 +0000
- Subject: [Bug c++/82247] [concepts] Name deduction in concepts fails depending on the argument type
- Auto-submitted: auto-generated
- References: <bug-82247-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82247
Casey Carter <Casey at Carter dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Casey at Carter dot net
--- Comment #4 from Casey Carter <Casey at Carter dot net> ---
This is not a bug: it's two-phase name lookup. At the point of definition for
Fooable:
#include <string>
#include <vector>
template <typename T>
bool concept Fooable = requires(const T& t) {
{ foo(t) }; // foo is unknown here
};
the compiler records the set of declarations it has seen for "foo" (the empty
set). When you later "instantiate" the concept foo can only resolve to (a) a
member of the (again, empty) set recorded at definition, or (b) a declaration
found by argument-dependent lookup. Since there are no associated namespaces
for fundamental types, only your user-defined type which has a "foo" defined in
its associated namespace successfully concept checks.