Lets imagine that we want to create alias for customization point object, like std::ranges::advance
.
Is there a good way to do this with minimal overhead? The following code fails in VS19 because it requires deleted copy constructor:
static constexpr auto advance_my = std::ranges::advance
The following code works in all 3 compilers (MSVC, LLVM, GCC) - Godbolt. But is this the best we can do?
static constexpr auto& advance_my = std::ranges::advance
Or should we just wrap standard function with perfect forwarding wrapper that has our special name?
Update: Basically what I want to achieve with this aliasing is to make this _IterOps struct usable on other compilers/STLs, it is used to abstract some libc++ algorithms like std::sort from input container type, so that std::sort, and std::ranges::sort uses the same implementation of sort: https://github.com/llvm/llvm-project/blob/main/libcxx/include/__algorithm/iterator_operations.h#L49
As you can see it requires me to alias some operations for std::ranges, and in case of normal iterators we define those operations almost from scratch.
static constexpr auto& advance_my = std::ranges::advance
looks great.
References are supposed to be aliases.