lundi 29 juin 2015

Overloading on valueness (rvalue/lvalue) of a function type

A little quiz:

#include <iostream>    

void foo(void(&f)(int))
{
    std::cout << "YOU LOSE" << std::endl;
}

void foo(void(&&f)(int))
{
     std::cout << "YOU WIN" << std::endl;
}

int main()
{
    //write winning code here!
    //(try to write something that will call the second overload of foo)
    return 0;
}

Is it possible to win? :)

I have to write something here, because stackoverflow wouldn't let me post something that is "mostly code". So here: blahblahblah.

Aucun commentaire:

Enregistrer un commentaire