On Sunday, 3 May 2020 at 12:19:30 UTC, Robert M. Münch wrote:
I'm doing some cursor-movement in a text-field. So, need to
find out where the cursor should be positioned.
The Unicode Consortium has some documentation related to
segmenting text that
you may find useful (notably, section 3):
https://unicode.org/reports/tr29
size_t drawableCharacterCount (CodePoints) (auto ref
CodePoints codePoints)
What does this line do?
I'm unsure as to which part is unclear, but an `auto ref`
parameter[1] in a
function template is essentially a parameter that receives the
argument by reference if the templated type is a value-type,
whereas if the templated type is a reference-type, it receives
the argument by value.
An explanation as code:
struct SomeValueType
{}
class SomeReferenceType
{}
void theFunction (Type) (auto ref Type thing)
{}
/+ theFunction!SomeValueType expands to: +/
void theFunction (ref SomeValueType thing)
{}
/+ theFunction!SomeReferenceType expands to: +/
void theFunction (SomeReferenceType thing)
{}
One advantage of auto ref parameters is that they accept literals
as arguments,
unlike a regular `ref` parameter.
[1]: https://dlang.org/spec/template.html#auto-ref-parameters