How do I change the used class upon available CPU features?
For example changing the used Vector4
-class by supported SIMD on the client side:
bool has_sse = get_cpuid_info( "sse" );
if( has_sse ) {
// use Vector4SIMD only in the entire app
} else {
// fallback to a plain Vector4-class
}
I can think of some ways (edit: added suggestions):
- using dynamic libraries
- dynamic cast's
- virtual dispatch
- compiler specific attributes
How is this, or similar behaviour done in nowadays software?
See Question&Answers more detail:os