Interesting question:) If I understood your goals correct, I can suggest a few solutions.
First uses template specialization, template default arguments and (of course) some macros.
Check this out:
If you use MSVC you can simplify example above eliminating and .
Trick: MSVC (2017 and maybe earlier versions) allow to omit that macros thresh, just ignoring the second declaration if they meet in the same compilation unit, like this:
BUT this will be not standard. Standard does not allow specifying default template args twice.
Meanwhile, this solution has few drawback:
When you include both headers, someone still can say which will use the backend specified by the first header you included. However, it would be better if compiler forced a person to specify a backend type explicitly in this circumstances, because otherwise it relies on the header inclusion order which is bad (say hello to macros).
Also, it assumes that both backends have the same API (like in my case)
Possible Fixes for those:
I am sure it is possible to make compiler give an error when both headers are included and no explicit backend was specified, but it probably involves more preprocessor things or some SFINAE...
If your backends do have different APIs, then you can insert a few where needed or (preferably) use C++17 if you have access to such cool features:)
- How fast is the Hellcat tank
- Does Vitamin E help reduce hair fall
- What is a fair card shuffling algorithm
- What is good for a homemade abortion
- Where do I travel this summer
- Do you use transcription service Why
- Does Cipralex make people tired
- Does content really increase website traffic
- Are some non metals magnetic
- Why cant I help every dog
- Whats the e in e commerce
- Can you 3D print a metal spring
- Do sociopathic genes exist
- What are long radio waves used for
- Why are our brave Indian soldiers flawless
- What comes after Rain Drop