Let's say I've defined a class like so:
#include <vector>
enum class cpu { sse2, sse4, avx, avx4 };
template <cpu architecture = current_cpu>
class foo // current_cpu defined based on compiler's target architecture
{
std::vector<int> data_;
public:
// methods...
};
I compile this 4 times for each of the target architectures (sse2, sse4, avx, avx2) for x86_64.
This generates 4 different classes foo<cpu::sse2>
, foo<cpu::sse4>
, etc
I then use some runtime dispatching to create the correct version at runtime and use some pointer trickery to invoke the methods on the instance in memory.
The question is related to the std::vector<int> _data
. Can the compiler decide not to inline all of std::vector
so that the linker is left with several versions of, say, a std::vector method compiled for multiple architectures and then link to the wrong one because they all have the same mangled name?