[Bug c++/66832] New: [concepts] parameters in requires clauses conflicting with function arguments
eric.niebler at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Jul 10 17:42:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66832
Bug ID: 66832
Summary: [concepts] parameters in requires clauses conflicting
with function arguments
Product: gcc
Version: c++-concepts
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: eric.niebler at gmail dot com
Target Milestone: ---
template <class T, class U, unsigned N>
requires requires (T& t, U &u) { t.foo(); u.foo(); }
void foo_all( T (&t)[N], U (&u)[N] ) {
for(auto& x : t)
x.foo();
for(auto& x : u)
x.foo();
}
struct S {
void foo() {}
};
int main() {
S rg[4] {};
foo_all(rg, rg);
}
Yields:
/cygdrive/c/Users/eric/Code/cmcstl2/test/iterator.cpp:4:23: error: conflicting
declaration ‘T (& t)[N]’
void foo_all( T (&t)[N], U (&u)[N] ) {
^
/cygdrive/c/Users/eric/Code/cmcstl2/test/iterator.cpp:3:25: note: previous
declaration as ‘T& t’
requires requires (T& t, U &u) { t.foo(); u.foo(); }
^
/cygdrive/c/Users/eric/Code/cmcstl2/test/iterator.cpp: In function ‘void
foo_all(U (&)[N])’:
/cygdrive/c/Users/eric/Code/cmcstl2/test/iterator.cpp:5:18: error: use of
parameter outside function body before ‘)’ token
for(auto& x : t)
^
/cygdrive/c/Users/eric/Code/cmcstl2/test/iterator.cpp: In function ‘int
main()’:
/cygdrive/c/Users/eric/Code/cmcstl2/test/iterator.cpp:17:17: error: no matching
function for call to ‘foo_all(S [4], S [4])’
foo_all(rg, rg);
^
/cygdrive/c/Users/eric/Code/cmcstl2/test/iterator.cpp:4:6: note: candidate:
template<class T, class U, unsigned int N> requires predicate(r
equires(T& t, U& u) {t->foo();u->foo();}) void foo_all(U (&)[N])
void foo_all( T (&t)[N], U (&u)[N] ) {
^
/cygdrive/c/Users/eric/Code/cmcstl2/test/iterator.cpp:4:6: note: template
argument deduction/substitution failed:
/cygdrive/c/Users/eric/Code/cmcstl2/test/iterator.cpp:17:17: note: candidate
expects 1 argument, 2 provided
foo_all(rg, rg);
^
More information about the Gcc-bugs
mailing list