Created
September 6, 2015 03:34
-
-
Save skystrife/5038af67c9d976d8520b to your computer and use it in GitHub Desktop.
Example of default argument of a member function template being a lambda causing GCC 4.8.1 to ICE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
#include <iostream> | |
struct herp | |
{ | |
template <class T> | |
void derp(T something, | |
std::function<void()> callback = [](){}) // <-- gcc 4.8.1 explodes here | |
{ | |
std::cout << "Something: " << something << "\n"; | |
// do some work | |
callback(); | |
} | |
}; | |
int main() | |
{ | |
herp h; | |
h.derp(); // by default, I want the callback to do nothing | |
h.derp([](){ std::cout << "wee I'm called by derp!\n" }); // but I can give a lambda to call if I want | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment