我继续读到这样做是不好的,但我不认为这些答案完全回答了我的具体问题.
在某些情况下,它似乎真的很有用.我想做类似以下的事情:
class Example {
private:
int val;
public:
void my_function() {
#if defined (__AVX2__)
#include <function_internal_code_using_avx2.h>
#else
#include <function_internal_code_without_avx2.h>
#endif
}
};
Run Code Online (Sandbox Code Playgroud)
如果#include在这个例子中使用代码中间是不好的,那么实现我想要做的事情的好方法是什么?也就是说,我试图在avx2可用和不可编译的情况下区分成员函数实现.