boost::function and free template function returning a dependent class template type
/* This doesn't work. Is it supposed to? If "broken" returns a "ret< int >" or an "x", then it does seem to work right. In case it's a known compiler issue, I'm using: Comeau C/C++ 4.3.3 (Aug 10 2003 15:39:53) for _MS_WINDOWS_x86_Beta8 */ #include "boost/function.hpp" using namespace boost; #include<ostream> using namespace std; template< typename x > struct ret{}; template< typename x > ret< x > broken( x f ) { cout << f << endl; return ret< x >(); } int main() { // function1< ret< int >, int > func; same problem function< ret< int > ( int ) > func = broken< int >; func( 42 ); }
On Apr 21, 2006, at 8:26 AM, Howard Gardner wrote:
/* This doesn't work. Is it supposed to?
If "broken" returns a "ret< int >" or an "x", then it does seem to work right.
In case it's a known compiler issue, I'm using:
Comeau C/C++ 4.3.3 (Aug 10 2003 15:39:53) for _MS_WINDOWS_x86_Beta8
It works for me on GCC 4.0.1, except that I need to change <ostream> to <iostream> (GCC bug, I believe). What error are you getting? Doug
Doug Gregor wrote:
On Apr 21, 2006, at 8:26 AM, Howard Gardner wrote:
/* This doesn't work. Is it supposed to?
If "broken" returns a "ret< int >" or an "x", then it does seem to work right.
In case it's a known compiler issue, I'm using:
Comeau C/C++ 4.3.3 (Aug 10 2003 15:39:53) for _MS_WINDOWS_x86_Beta8
It works for me on GCC 4.0.1, except that I need to change <ostream> to <iostream> (GCC bug, I believe). What error are you getting?
Doug
It ought to print: 42 It actually prints: 2292991 I can deliberately change what's on the stack, and it will print a different value. It looks like an uninitialized variable bug.
Doug Gregor wrote:
On Apr 21, 2006, at 8:26 AM, Howard Gardner wrote:
/* This doesn't work. Is it supposed to?
If "broken" returns a "ret< int >" or an "x", then it does seem to work right.
In case it's a known compiler issue, I'm using:
Comeau C/C++ 4.3.3 (Aug 10 2003 15:39:53) for _MS_WINDOWS_x86_Beta8
It works for me on GCC 4.0.1, except that I need to change <ostream> to <iostream> (GCC bug, I believe). What error are you getting?
Doug
I'm using boost the version in boost_1_33_1. (Sorry for not mentioning that sooner.)
participants (2)
-
Doug Gregor
-
Howard Gardner