Created
September 16, 2014 12:17
-
-
Save mgaunard/bd79a45cad4d08f1f03f to your computer and use it in GitHub Desktop.
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 <typeinfo> | |
| #include <cxxabi.h> | |
| template<class F, class Args> | |
| struct expr | |
| { | |
| Args args; | |
| }; | |
| auto plus = [](auto&& a0, auto&& a1) | |
| { | |
| return [a0, a1](auto f) { return f(a0, a1); }; | |
| }; | |
| auto terminal = [](auto&& a0) | |
| { | |
| return [a0](auto f) { return f(a0); }; | |
| }; | |
| int main() | |
| { | |
| int status; | |
| auto expr = plus(terminal(1), terminal(2)); | |
| std::cout << typeid(expr).name() << std::endl; | |
| std::cout << abi::__cxa_demangle(typeid(expr).name(), NULL, NULL, &status) << std::endl; | |
| /* ZNK3$_1clIZNK3$_0clIiEEDaOT_EUlS4_E_S6_EES3_S5_OT0_EUlS4_E_ | |
| * auto $_0::operator()<int>(int&&) const::{lambda(int&&)#1} $_1::operator()<auto $_0::operator()<int>(int&&) const::{lambda(int&&)#1}, auto $_0::operator()<int>(int&&) const::{lambda(int&&)#1}>({lambda(int&&)#1}, auto $_0::operator()<int>(int&&) const::{lambda(int&&)#1}&&) const::{lambda(int&&)#1} | |
| */ | |
| auto expr2 = plus(plus(terminal(1), plus(terminal(2.), terminal(3.f))), terminal(4l)); | |
| std::cout << typeid(expr2).name() << std::endl; | |
| std::cout << abi::__cxa_demangle(typeid(expr2).name(), NULL, NULL, &status) << std::endl; | |
| /* ZNK3$_1clIZNKS0_IZNK3$_0clIiEEDaOT_EUlS4_E_ZNKS0_IZNKS2_IdEES3_S5_EUlS4_E_ZNKS2_IfEES3_S5_EUlS4_E_EES3_S5_OT0_EUlS4_E_EES3_S5_SA_EUlS4_E_ZNKS2_IlEES3_S5_EUlS4_E_EES3_S5_SA_EUlS4_E_ | |
| * auto $_0::operator()<int>(int&&) const::{lambda(int&&)#1} $_1::operator()<auto $_0::operator()<int>(int&&) const::{lambda(int&&)#1}, double $_0::operator()<double>({lambda(int&&)#1}) const::{lambda(int&&)#1} $_1::operator()<double $_0::operator()<double>({lambda(int&&)#1}) const::{lambda(int&&)#1}, float $_0::operator()<float>({lambda(int&&)#1}) const::{lambda(int&&)#1}>({lambda(int&&)#1}, float $_0::operator()<float>({lambda(int&&)#1}) const::{lambda(int&&)#1}&&) const::{lambda(int&&)#1}>({lambda(int&&)#1}, float $_0::operator()<float>({lambda(int&&)#1}) const::{lambda(int&&)#1}) const::{lambda(int&&)#1} $_1::operator()<auto $_0::operator()<int>(int&&) const::{lambda(int&&)#1} $_1::operator()<auto $_0::operator()<int>(int&&) const::{lambda(int&&)#1}, double $_0::operator()<double>({lambda(int&&)#1}) const::{lambda(int&&)#1} $_1::operator()<double $_0::operator()<double>({lambda(int&&)#1}) const::{lambda(int&&)#1}, float $_0::operator()<float>({lambda(int&&)#1}) const::{lambda(int&&)#1}>({lambda(int&&)#1}, float $_0::operator()<float>({lambda(int&&)#1}) const::{lambda(int&&)#1}&&) const::{lambda(int&&)#1}>({lambda(int&&)#1}, float $_0::operator()<float>({lambda(int&&)#1}) const::{lambda(int&&)#1}) const::{lambda(int&&)#1}, long $_0::operator()<long>({lambda(int&&)#1}) const::{lambda(int&&)#1}>({lambda(int&&)#1}, float $_0::operator()<float>({lambda(int&&)#1}) const::{lambda(int&&)#1}) const::{lambda(int&&)#1} | |
| */ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment