在
cnvt.h
标题中有:
template <typename t_to, typename t_from> std::optional<t_to> cnvt(t_from);
在标题
int.h
中,我们有:
#include "cnvt.h"
template <>
std::optional<uint8_t> cnvt<uint8_t, const char *>(const char *) {
// actual code replaced for simplicity
return {};
}
事实上,
clang-tidy
报道
clang 报告“int.h:: Included header cvnt.h is not used directly (修复可用)包含的头文件 cvnt.h 不直接使用(修复 可用)
如果删除
#include "cnvt.h"
,它会报告
int.h:9:24:没有函数模板匹配函数模板专业化'cnvt'
我搜索了 StackOverflow,关于函数模板专业化的帖子没有帮助。