Extract C++ template parameters

前端 未结 5 1787
轻奢々
轻奢々 2020-12-05 13:26

Although I\'m doubtful, I\'m curious as to whether it\'s possible to extract primitive-type template parameters from an existing type, perhaps using RTTI.

For exampl

5条回答
  •  长情又很酷
    2020-12-05 13:55

    I like Marc Garcia's answer because it shows how to extract the template parameter in a generic way, but I believe his example can be simpler:

    #include 
    #include 
    
    template
    struct MyType {};
    
    template