Skip to content

Instantly share code, notes, and snippets.

@mgaunard
Created September 16, 2014 11:32
Show Gist options
  • Select an option

  • Save mgaunard/5f627ec64dc5ba712496 to your computer and use it in GitHub Desktop.

Select an option

Save mgaunard/5f627ec64dc5ba712496 to your computer and use it in GitHub Desktop.
#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