I am trying to do a simple library where the object is a point on the xy-axis.
I want to be able to use literals like this:
Point a = (3,4);
where (3,4)
is a point literal.
I read about user defined literals, but (as I understood) this seems to be impossible.
May be "(3,4)"_P
is possible as I understand it.
However, I found on this page interesting use of user defined literals as follows:
#include <iostream>
#include <complex>
int main()
{
using namespace std::complex_literals;
std::complex<double> c = 1.0 + 1i;
std::cout << "abs" << c << " = " << abs(c) << '\n';
}
I can under stand the part 1i
as a user defined literal, but not the whole thing 1.0 + 1i
.
What I am missing, and what is the nearest possible way of getting a literal similar to (x,y)
without using "
.