Why can't the template argument be deduced when it is used as template parameter to another template?

前端 未结 4 2027
无人共我
无人共我 2020-11-22 09:02

What is wrong in this code?

#include 

template
struct TMap
{
    typedef std::map Type;
};

template

        
4条回答
  •  执笔经年
    2020-11-22 09:50

    Exactly what the compiler error message says: in TMap::Type, T is not deduceable according to the standard. The motivation for this is probably that it isn't technically possible to implement: the compiler would have to instantiate all possible TMap in order to see if one (and only one) matched the type you passed. And there is an infinite number of TMap.

提交回复
热议问题