1

Consider that some library defines:

namespace NS {
    constexpr atype operator ""_suffix(const char*, std::size_t);
};

If I don't like the name _suffix (maybe it clashes with some other library, or it is in stark contrast with my naming convention): Am I able to "rename" the operator?

using _myalias = NS::operator ""_suffix`;  // syntax error
using _myalias = NS::""_suffix`;  // syntax error
using _myalias = NS::_suffix`;  // undefined (`operator ""` is part of its name)

constexpr decltype(auto) operator ""_myalias(const char *str, std::size_t len)
{
    return NS::operator ""_suffix(str, len);  // very verbose, but it works
}

So, is there a simple syntax to define an alias for a user defined literal?

Kijewski
  • 25,517
  • 12
  • 101
  • 143
  • 2
    The first three don't work because `using` is for types, not functions. I feel like the last one is the only way, unfortunately. – tkausl Apr 01 '19 at 16:45
  • @tkausl, I did not think about it properly. Operators are only functions with a little sugar added. I leave this question open in case someone finds some solution in C++2b or some point in the future. – Kijewski Apr 02 '19 at 05:43

0 Answers0