3 ms·
Good discussion and I would love more lightweight type creation in C++. The "Allow internal functionality" proposal doesn't fully work as-is. Imagine you have
by ulber 8y ago
Good discussion and I would love more lightweight type creation in C++.
The "Allow internal functionality" proposal doesn't fully work as-is. Imagine you have a type Scalar, which has a function:
Scalar Scalar::scale(Scalar);
If you now do
typedecl Scalar Celcius;
you'd get a function for it with the following signature:
Celcius Celcius::scale(Celcius);
However, the function you'd actually want is
Celcius Celcius::scale(Scalar);
The root problem here is that since the original type mixes different uses of the type, you can't blindly convert all those uses to the new type.
- pierrebai 8y agoThis is discussed in the section about including external functionality through a mechanism of guided mapping. In the proposed syntax, that would be done like this: typedecl Celsius clone Scalar Scalar::scale(Scalar) -> Celsius Celsius::scale(Scalar); (In the blog post, the example given is with std::pow())