Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

#ActualAmeise

Posted 03 May 2012 - 11:43 AM


However, a normal function pointer worked:

A conversion to function pointer exists for the function object types of lambdas that don't capture any variables. It should be pretty obvious why lambdas that do capture variables don't have that conversion.


#include <cstdio>
#include <functional>
 
int main ()
{
    volatile int a = 5;
    std::function<void ()> func = [a] () { printf("%i\n", a); };
    func();
    return 0;
}

That code compiles and executes properly on both VC10, 11, and GCC.

#2Ameise

Posted 03 May 2012 - 11:42 AM


However, a normal function pointer worked:

A conversion to function pointer exists for the function object types of lambdas that don't capture any variables. It should be pretty obvious why lambdas that do capture variables don't have that conversion.


#include <cstdio>
#include <functional>

int main ()
{
		volatile int a = 5;
		std::function<void ()> func = [a] () { printf("%i\n", a); };
	    func();
		return 0;
}

That code compiles and executes properly on both VC10, 11, and GCC.

#1Ameise

Posted 03 May 2012 - 11:41 AM


However, a normal function pointer worked:

A conversion to function pointer exists for the function object types of lambdas that don't capture any variables. It should be pretty obvious why lambdas that do capture variables don't have that conversion.


#include <cstdio>
#include <functional>

int main ()
{
	    volatile int a = 5;
	    std::function<void ()> func = [a] () { printf("%i\n", a); };
func();
	    return 0;
}

That code compiles and executes properly on both VC10, 11, and GCC.

PARTNERS