C++ template compilation error: expected primary-expression before ‘>’ token

后端 未结 1 743
独厮守ぢ
独厮守ぢ 2020-12-07 22:58

This code compiles and works as expected (it throws at runtime, but never mind):

#include 
#include 

vo         


        
相关标签:
1条回答
  • 2020-12-07 23:22

    You need to do:

    std::cout << pt.template get<std::string>("path");
    

    Use template in the same situation as typename, except for template members instead of types.

    (That is, since pt::get is a template member dependent on a template parameter, you need to tell the compiler it's a template.)

    0 讨论(0)
提交回复
热议问题