Template template parameters and variadic templates with gcc 4.4

前端 未结 2 1654
情深已故
情深已故 2021-01-11 12:47

I\'m using gcc 4.4 on Debian squeeze. Consider the following code.

#include 
#include 
using std::map;
using std::string;

// Args l         


        
2条回答
  •  攒了一身酷
    2021-01-11 13:48

    As discussed in the edits, my question appears to tickle the same bug as the linked question, Variadic template templates and perfect forwarding. In particular, the workaround given there in a link also works in my case. The modified code that works is as follows:

    #include 
    #include 
    using std::map;
    using std::string;
    
    template  class C,
          typename... Args>
    struct X
    {
      typedef C type;
    };
    
    template  class C,
          typename... Args>
    typename X::type foo()
    {
      C x;
      return x;
    }
    
    int main(void)
    {
      map a = foo();
    }
    

提交回复
热议问题