File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -21,13 +21,27 @@ extension std.string {
21
21
/// Swift string.
22
22
public init ( _ string: String ) {
23
23
self = string. withCString ( encodedAs: UTF8 . self) { buffer in
24
+ #if os(Windows)
25
+ // Use the 2 parameter constructor.
26
+ // The MSVC standard library has a enable_if template guard
27
+ // on the 3 parameter constructor, and thus it's not imported into Swift.
28
+ std. string ( buffer, string. utf8. count)
29
+ #else
24
30
std. string ( buffer, string. utf8. count, . init( ) )
31
+ #endif
25
32
}
26
33
}
27
34
28
35
public init ( _ string: UnsafePointer < CChar > ? ) {
29
36
if let str = string {
37
+ #if os(Windows)
38
+ // Use the 2 parameter constructor.
39
+ // The MSVC standard library has a enable_if template guard
40
+ // on the 3 parameter constructor, and thus it's not imported into Swift.
41
+ self . init ( str, UTF8 . _nullCodeUnitOffset ( in: str) )
42
+ #else
30
43
self . init ( str, UTF8 . _nullCodeUnitOffset ( in: str) , . init( ) )
44
+ #endif
31
45
} else {
32
46
self . init ( )
33
47
}
You can’t perform that action at this time.
0 commit comments