Skip to content

Instantly share code, notes, and snippets.

@skystrife
Created September 6, 2015 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save skystrife/5038af67c9d976d8520b to your computer and use it in GitHub Desktop.
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
#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