34
34
}
35
35
36
36
extern (C++ , (StdNamespace)):
37
+ @nogc :
37
38
38
39
// /
39
40
alias string_view = basic_string_view! char ;
40
- // alias u16string_view = basic_string_view!wchar; // TODO: can't mangle these yet either...
41
- // alias u32string_view = basic_string_view!dchar;
42
- // alias wstring_view = basic_string_view!wchar_t; // TODO: we can't mangle wchar_t properly (yet?)
41
+ // /
42
+ alias u16string_view = basic_string_view! wchar ;
43
+ // /
44
+ alias u32string_view = basic_string_view! dchar ;
45
+ // /
46
+ alias wstring_view = basic_string_view! wchar_t;
43
47
44
48
45
49
/**
@@ -58,6 +62,7 @@ extern(C++, class) struct basic_string_view(T, Traits = char_traits!T)
58
62
{
59
63
extern (D ):
60
64
pragma (inline, true ):
65
+ pure nothrow @nogc :
61
66
62
67
// /
63
68
enum size_type npos = size_type.max;
@@ -76,75 +81,51 @@ pragma(inline, true):
76
81
// /
77
82
alias as_array this ;
78
83
84
+ // /
85
+ this (const (T)[] str) @trusted { __data = str.ptr; __size = str.length; }
86
+
79
87
// /
80
88
alias length = size;
81
89
// /
82
90
alias opDollar = length;
83
91
// /
84
- bool empty () const nothrow @safe @nogc { return size() == 0 ; }
92
+ size_type size () const @safe { return __size; }
93
+ // /
94
+ bool empty () const @safe { return __size == 0 ; }
85
95
86
96
// /
87
- ref const (T) front () const nothrow @safe @nogc { return this [ 0 ] ; }
97
+ const (T)* data () const @safe { return __data ; }
88
98
// /
89
- ref const (T) back () const nothrow @safe @nogc { return this [$ - 1 ]; }
99
+ const (T)[] as_array () const @trusted { return __data[ 0 .. __size ]; }
90
100
101
+ // /
102
+ ref const (T) at (size_type i) const @trusted { return __data[0 .. __size][i]; }
103
+
104
+ // /
105
+ ref const (T) front () const @safe { return this [0 ]; }
106
+ // /
107
+ ref const (T) back () const @safe { return this [$- 1 ]; }
108
+
109
+ private :
110
+ // use the proper field names from C++ so debugging doesn't get weird
91
111
version (CppRuntime_Windows)
92
112
{
93
- // /
94
- this (const (T)[] str) nothrow @trusted @nogc { _Mydata = str.ptr; _Mysize = str.length; }
95
-
96
- // /
97
- size_type size () const nothrow @safe @nogc { return _Mysize; }
98
- // /
99
- const (T)* data () const nothrow @safe @nogc { return _Mydata; }
100
- // /
101
- const (T)[] as_array () const inout @trusted @nogc { return _Mydata[0 .. _Mysize]; }
102
- // /
103
- ref const (T) at (size_type i) const nothrow @trusted @nogc { return _Mydata[0 .. _Mysize][i]; }
104
-
105
- version (CppRuntime_Microsoft )
106
- {
107
- import core.stdcpp.xutility : MSVCLinkDirectives;
108
- mixin MSVCLinkDirectives! false ;
109
- }
110
-
111
- private :
112
113
const_pointer _Mydata;
113
114
size_type _Mysize;
115
+
116
+ alias __data = _Mydata;
117
+ alias __size = _Mysize;
114
118
}
115
119
else version (CppRuntime_Gcc )
116
120
{
117
- // /
118
- this (const (T)[] str) nothrow @trusted @nogc { _M_str = str.ptr; _M_len = str.length; }
119
-
120
- // /
121
- size_type size () const nothrow @safe @nogc { return _M_len; }
122
- // /
123
- const (T)* data () const nothrow @safe @nogc { return _M_str; }
124
- // /
125
- const (T)[] as_array () const nothrow @trusted @nogc { return _M_str[0 .. _M_len]; }
126
- // /
127
- ref const (T) at (size_type i) const nothrow @trusted @nogc { return _M_str[0 .. _M_len][i]; }
128
-
129
- private :
130
121
size_t _M_len;
131
122
const (T)* _M_str;
123
+
124
+ alias __data = _M_str;
125
+ alias __size = _M_len;
132
126
}
133
127
else version (CppRuntime_Clang )
134
128
{
135
- // /
136
- this (const (T)[] str) nothrow @trusted @nogc { __data = str.ptr; __size = str.length; }
137
-
138
- // /
139
- size_type size () const nothrow @safe @nogc { return __size; }
140
- // /
141
- const (T)* data () const nothrow @safe @nogc { return __data; }
142
- // /
143
- const (T)[] as_array () const nothrow @trusted @nogc { return __data[0 .. __size]; }
144
- // /
145
- ref const (T) at (size_type i) const nothrow @trusted @nogc { return __data[0 .. __size][i]; }
146
-
147
- private :
148
129
const value_type* __data;
149
130
size_type __size;
150
131
}
0 commit comments