I like spans, so I use gsl::span
here and there. But - in C++20, it's going to be std::span
instead*. I use std::optional
, but for C++14 code, it needs to be std::experimental::optional
. And so on.
What's an idiomatic and sort-of future-proof way to make the compile-time choice between these variants (sometimes perhaps more than two), so that my actual code can just use one sequence-of-tokens which compile into the correctly-chosen span, or optional, or other similar construct?
Note: I want to avoid polluting the global namespace.
* Well, technically I could use gsl::span
later as well, but the idea in this question is to use what's in the standard once it's available, and the nearest alternative, before that.
I usually use something like this:
Now in your code just use: