Created
September 16, 2014 11:32
-
-
Save mgaunard/5f627ec64dc5ba712496 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> | |
| template<class T> | |
| void print_type(T) | |
| { | |
| std::cout << __PRETTY_FUNCTION__ << std::endl; | |
| std::cout << typeid(T).name() << std::endl; | |
| } | |
| template<class T> | |
| struct opaque {}; | |
| template<class T> | |
| opaque<T> make_opaque(T) | |
| { | |
| return {}; | |
| } | |
| template<class RHS> | |
| void operator_assign(RHS) | |
| { | |
| print_type(make_opaque([]{})); | |
| } | |
| struct the_long_template_type_you_want_to_hide {}; | |
| int main(int argc, char** argv) { | |
| operator_assign(the_long_template_type_you_want_to_hide()); | |
| return 0; | |
| } | |
| // output: | |
| // void print_type(T) [T = opaque<<lambda at test_expr.cpp:23:28> >] | |
| // 6opaqueIZ15operator_assignI39the_long_template_type_you_want_to_hideEvT_EUlvE_E |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment