Boost logo

Boost :

From: SourceForge.net (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:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1025124&group_id=7586

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:
Submitter:
John Engström
<john.engstrom\spam\@\spam\solcorp.com>

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) {

            ...
            foo();
            ...
        }

        ...
    };

    my_functor my_functor_instance;

    boost::function2<void, int, int> my_function1 =
boost::ref(my_functor_instance);
    boost::function2<void, int, int> my_function2 =
my_functor_instance;
}

/////////////////// 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
'boost::function2<R,T0,T1>'
        with
        [
            R=void,
            T0=int,
            T1=int
        ]

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1025124&group_id=7586

-------------------------------------------------------
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.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk