在 C++ 中使用 Trompeloeil 模拟单元测试时,如何使用 anunordered_map
作为返回类型?
// This example works fine
// return type is void, my_function takes no arguments
MAKE_MOCK0(my_function, void(), override);
// This is what I'm trying to do but fails
MAKE_MOCK0(my_function, std::unordered_map<std::string, int>(), override);
Visual Studio 给出以下 IntelliSense 错误,
- C2976 -
std::unordered_map
: 模板参数太少 - C2955 -
std::unordered_map
:使用类模板需要模板参数列表 - C2923 -
trompeloeil::param_list
:std::_Hash<_Traits::size>
不是参数类型的有效模板类型参数T
- C2143
>
-之前缺少语法错误;
- C2955 -
trompeloeil::param_list
使用类模板需要模板参数列表 - C2338 - 函数签名没有 0 个参数
- C3203 -非专业
unordered_map
类不能用作模板参数“Sig”的模板参数,需要一个真实类型 - C4346 -
std::unordered_map::type
从属名称不是类型 - C2923 -
trompeloeil::identity_type
:std::unordered_map::type
不是参数类型的有效模板类型参数T
- C3203 -未专门化
unordered_map
的类不能用作模板参数“T”的模板参数,应为真实类型