Created
December 13, 2015 12:16
-
-
Save 2bbb/d74336774474334cb05c to your computer and use it in GitHub Desktop.
black_magic
This file contains hidden or 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 <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