Boost logo

Boost :

From: (noreply_at_[hidden])
Date: 2004-09-09 08:47:04

Bugs item #1025124, was opened at 2004-09-09 06:47
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:

Category: functional
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Mark Rodgers (mark_rodgers)
Summary: boost::function doesn't accept classes declared in functions

Initial Comment:
John Engström

Using MSVC 7.1, I use a functor defined in-scope, as in
the following example.

///////////////////// code snippet

void bar()

    struct my_functor
        void operator () (int arg1, int arg2) {



    my_functor my_functor_instance;

    boost::function2<void, int, int> my_function1 =
    boost::function2<void, int, int> my_function2 =

/////////////////// explanation

This fails to compile, see below for error messages,
however if I move the declaration of the functor out of
the function bar(), it compiles fine. Perhaps it only
happens with MSVC.

/////////////////// error messages

main.cpp(116): error C2893: Failed to specialize
function template 'const boost::reference_wrapper<T>
boost::ref(T &)'

main.cpp(117): error C2440: 'initializing' : cannot
convert from 'WinMain::my_functor' to


You can respond by visiting:

This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
Boost-bugs mailing list

Boost list run by bdawes at, gregod at, cpdaniel at, john at