public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44162] New: cannot match function ref argument to dependent std::enable_if::type
@ 2010-05-16 21:32 potswa at mac dot com
2010-05-16 22:17 ` [Bug c++/44162] [C++0x] " paolo dot carlini at oracle dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: potswa at mac dot com @ 2010-05-16 21:32 UTC (permalink / raw)
To: gcc-bugs
Given some function
void ff(); // any signature
This function is callable:
void rcv_f( typename std::enable_if< true, decltype(ff) >::type const &f ) {}
This function template does not produce a candidate:
template< class F >
void rcv_f( typename std::enable_if< true, F >::type const &f ) {}
This function template prints two identical lines:
template< class F >
void rcv_f( F const &f ) {
std::cerr << typeid( typename std::enable_if< true, F >::type ).name() <<
std::endl;
std::cerr << typeid( F ).name() << std::endl;
}
The problem does not occur with functors. The first example still works if
trivially made into a template, so the dependent argument matters rather than
the dependent context.
--
Summary: cannot match function ref argument to dependent
std::enable_if::type
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: potswa at mac dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44162
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/44162] [C++0x] cannot match function ref argument to dependent std::enable_if::type
2010-05-16 21:32 [Bug c++/44162] New: cannot match function ref argument to dependent std::enable_if::type potswa at mac dot com
@ 2010-05-16 22:17 ` paolo dot carlini at oracle dot com
2010-05-17 6:06 ` potswa at mac dot com
2010-05-17 9:35 ` paolo dot carlini at oracle dot com
2 siblings, 0 replies; 4+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-05-16 22:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from paolo dot carlini at oracle dot com 2010-05-16 22:17 -------
Please provide a short self-contained testcase, thanks.
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Summary|cannot match function ref |[C++0x] cannot match
|argument to dependent |function ref argument to
|std::enable_if::type |dependent
| |std::enable_if::type
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44162
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/44162] [C++0x] cannot match function ref argument to dependent std::enable_if::type
2010-05-16 21:32 [Bug c++/44162] New: cannot match function ref argument to dependent std::enable_if::type potswa at mac dot com
2010-05-16 22:17 ` [Bug c++/44162] [C++0x] " paolo dot carlini at oracle dot com
@ 2010-05-17 6:06 ` potswa at mac dot com
2010-05-17 9:35 ` paolo dot carlini at oracle dot com
2 siblings, 0 replies; 4+ messages in thread
From: potswa at mac dot com @ 2010-05-17 6:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from potswa at mac dot com 2010-05-17 06:06 -------
Sorry, that was completely wrong. I thought I'd isolated a testcase with the
above code plus int main() { return rcv_f<decltype(f)>(f); }, but that actually
does work.
It seems the problem is completely different. The testcase below suggests that
decltype somehow cannot recurse in the presence of a reference to function
type.
#include <tuple>
#include <type_traits> // aside: std::result_of belongs in <type_traits>
#include <functional> // not <functional>.
template< class T, class F,
size_t tuple_index0 = std::tuple_size<T>::value,
size_t... tuple_indexes >
typename std::result_of< typename std::enable_if< tuple_index0 == 0,
F( typename std::tuple_element< tuple_indexes - 1, T >::type... )
>::type >::type
apply( T const &t, F f ) {
return f( std::get< tuple_indexes - 1 >( t )... );
}
template< class T, class F,
size_t tuple_index0 = std::tuple_size<T>::value,
size_t... tuple_indexes >
decltype( apply< typename std::enable_if< tuple_index0 != 0, T >::type,
F, tuple_index0 - 1, tuple_index0, tuple_indexes... >
( std::declval<T>(), std::declval<F>() ) )
apply( T const &t, F f ) {
return apply< T, F, tuple_index0 - 1, tuple_index0, tuple_indexes... >
( t, f );
}
void f() {}
void g( int ) {}
void h( int, int ) {}
struct a { void operator()( int, int ) {} };
int main() {
// these cases work:
apply( std::make_tuple(), f );
apply( std::make_tuple( 0 ), g );
apply< std::tuple< int, int >, void (&)(int, int), 1, 2 >( std::make_tuple(
0, 0 ), h );
apply( std::make_tuple( 0, 0 ), a() );
// this does not:
apply( std::make_tuple( 0, 0 ), h );
}
Either the subject of this bug should be changed or I should open a new bug.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44162
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/44162] [C++0x] cannot match function ref argument to dependent std::enable_if::type
2010-05-16 21:32 [Bug c++/44162] New: cannot match function ref argument to dependent std::enable_if::type potswa at mac dot com
2010-05-16 22:17 ` [Bug c++/44162] [C++0x] " paolo dot carlini at oracle dot com
2010-05-17 6:06 ` potswa at mac dot com
@ 2010-05-17 9:35 ` paolo dot carlini at oracle dot com
2 siblings, 0 replies; 4+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-05-17 9:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from paolo dot carlini at oracle dot com 2010-05-17 09:35 -------
Ok, then please open a new PR including a *minimal* testcase.
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44162
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-17 9:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-16 21:32 [Bug c++/44162] New: cannot match function ref argument to dependent std::enable_if::type potswa at mac dot com
2010-05-16 22:17 ` [Bug c++/44162] [C++0x] " paolo dot carlini at oracle dot com
2010-05-17 6:06 ` potswa at mac dot com
2010-05-17 9:35 ` paolo dot carlini at oracle dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).