Why can't C++ deduce template type from assignment?

后端 未结 5 1067
盖世英雄少女心
盖世英雄少女心 2020-12-06 09:39

int x = fromString(\"test\") :could not deduce template argument for \'ValueType\'

int x = fromString(\"test\") : works

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 10:17

    It looks like your template has the return type templated which cannot be automatically deduced which is why you need to add it in here.

提交回复
热议问题