Convert wchar* to wstring?
Basile B. via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Apr 5 00:36:10 PDT 2016
On Tuesday, 5 April 2016 at 01:21:55 UTC, Thalamus wrote:
> I'm sorry for this total newbie question, but for some reason
> this is eluding me. [...]
You've been given the right answer by the other participants but
I'd like to share this simple helper range from my user lib:
auto nullTerminated(C)(C c)
if (isPointer!C && isSomeChar!(PointerTarget!(C)))
{
struct NullTerminated(C)
{
private C _front;
///
this(C c)
{
_front = c;
}
///
@property bool empty()
{
return *_front == 0;
}
///
auto front()
{
return *_front;
}
///
void popFront()
{
++_front;
}
///
C save()
{
return _front;
}
}
return NullTerminated!C(c);
}
The idea is to get rid of the conversion and to process directly
the pointer in all phobos function.
More information about the Digitalmars-d-learn
mailing list