I'm playing around with std::tr1 in gcc 4.1.0 using a piece of code borrowed from 'Effective C++ Third Ed' and I cannot figure out the two different error messages.
Undoubtedly there is some subtle issue at work, but it escapes me. Thanks Code lifted and modified from pp 173..175: ------- #include <tr1/functional> class B; int defaultFn( const B & ) { return 0; } struct DefaultFnObj { int operator()( const B & ) const { return 0; } }; class B { public: typedef std::tr1::function<int ( const B & )> Fn_t; explicit B( Fn_t fn = defaultFn ) : m_fn( fn ) {} int fn() const { return m_fn( *this ); } private: Fn_t m_fn; }; int main() { // This works DefaultFnObj fn0; B b0( fn0 ); const int rc0 = b0.fn(); // This doesn't because of the explicit constructor call DefaultFnObj fn1(); B b1( fn1 ); const int rc1 = b1.fn(); // This doesn't either (similar to above, but different compiler error) B b2( DefaultFnObj() ); return rc0 + rc1 + b2.fn(); } ------