daily pastebin goal
16%
SHARE
TWEET

c++filt and boost demangle failure

a guest Feb 13th, 2018 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <boost/core/demangle.hpp>
  3.  
  4. template <typename T>
  5. auto mangled (T t) {
  6.     return typeid(t).name();
  7. }
  8.  
  9. template <typename T>
  10. auto demangled (T t) {
  11.     return boost::core::demangle(mangled(t));
  12. }
  13.  
  14. #define SYM struct { using symbolic = void; }
  15. #define TSYM(Name) struct Name { using symbolic = void; }
  16.  
  17. template <typename... Us> TSYM(ListType);
  18.  
  19. template <typename... Ts>
  20. auto list (Ts...) {
  21.     return ListType<Ts...>{};
  22. }
  23.  
  24. template <typename T, typename U>
  25. auto operator+ (T t, U u) {
  26.     SYM plus;
  27.     return list(plus, t, u);
  28. }
  29.  
  30. int main () {
  31.     SYM a;
  32.     SYM b;
  33.     auto sum1 = a + b;
  34.     auto sum2 = a + b + a;
  35.  
  36.     std::cout << mangled(a) << std::endl
  37.               << demangled(a) << std::endl
  38.               << mangled(b) << std::endl
  39.               << demangled(b) << std::endl
  40.               << mangled(sum1) << std::endl
  41.               << demangled(sum1) << std::endl
  42.               << mangled(sum2) << std::endl
  43.               << demangled(sum2) << std::endl;
  44.     return 0;
  45. }
  46.  
  47. /* OUTPUT
  48. Z4mainEUt_
  49. main::{unnamed type#1}
  50. Z4mainEUt0_
  51. main::{unnamed type#2}
  52. 8ListTypeIJZplIZ4mainEUt_Z4mainEUt0_EDaT_T0_EUt_S1_S2_EE
  53. ListType<auto operator+<main::{unnamed type#1}, main::{unnamed type#2}>(main::{unnamed type#1}, main::{unnamed type#2})::{unnamed type#1}, {unnamed type#1}, main::{unnamed type#1}>
  54. 8ListTypeIJZplIS_IJZS0_IZ4mainEUt_Z4mainEUt0_EDaT_T0_EUt_S1_S2_EES1_EDaS3_S4_EUt_S6_S1_EE
  55. 8ListTypeIJZplIS_IJZS0_IZ4mainEUt_Z4mainEUt0_EDaT_T0_EUt_S1_S2_EES1_EDaS3_S4_EUt_S6_S1_EE
  56. */
  57.  
  58. /* OUTPUT PIPED TO 'c++filt -t'
  59. main::{unnamed type#1}
  60. main::{unnamed type#1}
  61. main::{unnamed type#2}
  62. main::{unnamed type#2}
  63. ListType<auto operator+<main::{unnamed type#1}, main::{unnamed type#2}>(main::{unnamed type#1}, main::{unnamed type#2})::{unnamed type#1}, {unnamed type#1}, main::{unnamed type#1}>
  64. ListType<auto operator+<main::{unnamed type#1}, main::{unnamed type#2}>(main::{unnamed type#1}, main::{unnamed type#2})::{unnamed type#1}, {unnamed type#1}, main::{unnamed type#1}>
  65. 8ListTypeIJZplIS_IJZS0_IZ4mainEUt_Z4mainEUt0_EDaT_T0_EUt_S1_S2_EES1_EDaS3_S4_EUt_S6_S1_EE
  66. 8ListTypeIJZplIS_IJZS0_IZ4mainEUt_Z4mainEUt0_EDaT_T0_EUt_S1_S2_EES1_EDaS3_S4_EUt_S6_S1_EE
  67. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top