Hi all,
the following code compiles well with g++ 12.1.0, but not with clang++ 14.0.6
#include <iostream>
#include <string>
using T = long double;
constexpr T operator"" _€(T amount)
{
return amount;
}
constexpr T operator"" _$(T amount)
{
return amount;
}
int main()
{
auto euros{ 11.02_€ };
auto dollars{ 12.02_$ };
std::cout << euros << '\n';
std::cout << dollars << '\n';
return 0;
}
The main reason is that clang++ does not accept € and $ in user defined literals.
So far, so good.
The problem then arises with clang-format, which inserts a space between the _ and the $,
auto euros{ 11.02_€ };
auto dollars{ 12.02_ $ };
but leaves _€ as well as the lines
constexpr T operator"" _€(T amount)
constexpr T operator"" _$(T amount)
unchanged.
Do I have to set a special option in my .clang-format file?
(I can provide the current file, if needed for the solution)