Skip to content

Instantly share code, notes, and snippets.

@2bbb
Created December 13, 2015 12:16
Show Gist options
  • Select an option

  • Save 2bbb/d74336774474334cb05c to your computer and use it in GitHub Desktop.

Select an option

Save 2bbb/d74336774474334cb05c to your computer and use it in GitHub Desktop.
black_magic
#include <iostream>
#include <type_traits>
template<typename T, typename U>
struct lambda_check {
static constexpr bool value = !std::is_same<T, U>::value;
};
template <typename fun1, typename fun2>
constexpr bool is_lambda_(fun1, fun2) {
return lambda_check<fun1, fun2>::value;
}
#define is_lambda(f) is_lambda_(f, f)
void f() {}
int main(int argc, char *argv[]) {
std::cout << is_lambda(f) << std::endl;
std::cout << is_lambda([](){}) << std::endl;
auto g = [](){};
std::cout << is_lambda(g);
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment