For now, user-defined literals accept a limited set of types as input parameter (see here). Is there any plan to accept any type as input parameter, and if not why is that ?
For example, I might want to be able to get a std::chrono::duration in different format (seconds, milliseconds, etc), and would do something like
constexpr double operator"" _s(std::chrono::nanosecond time)
{
return std::chrono::duration_cast<std::chrono::duration<double, std::chrono::seconds::period>>(time).count();
}
constexpr long operator"" _us(std::chrono::nanoseconds time)
{
return std::chrono::duration_cast<std::chrono::microseconds>(time).count();
}
// And so on ...
int main()
{
auto t0 = std::chrono::high_resolution_clock::now();
// do some stuff
auto t1 = std::chrono::high_resolution_clock::now();
std::cout << "Time in seconds : " << (t1 - t0)_s << "s\n";
std::cout << "Time in microseconds : " << (t1 - t0)_us << "µs\n";
return 0;
}