相关疑难解决方法(0)

强制不合格的名称是依赖值

某些遗留测试框架代码中存在一种模式,它依赖于Visual C++的两阶段查找,在移植到其他编译器时会引起麻烦.我知道有许多解决方案来解决这个问题,但都需要"广泛的"结构变化.

虽然我很确定没有,但我很好奇是否存在一个"简单"的黑客攻击,它可以在符合标准的编译器中获得所需的行为,并且只需要一小组所需的更改.

该示例中显示了该模式:

#include <cstdio>

// global "system" function to test; generally something like `fopen` in a real test
const char* GetString() { return "GLOBAL"; }

// provides no overrides of the standard system functions being tested
struct NoOverrides {};

// set of functions overriding the system functions being tested
struct TestOverrides {
  // if this were `fopen` this might be a version that always fails
  static const char* GetString() { return "OVERRIDE"; }
};

// test case
template …
Run Code Online (Sandbox Code Playgroud)

c++

14
推荐指数
1
解决办法
365
查看次数

标签 统计

c++ ×1