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 {
2121 /// Swift string.
2222 public init ( _ string: String ) {
2323 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
2430 std. string ( buffer, string. utf8. count, . init( ) )
31+ #endif
2532 }
2633 }
2734
2835 public init ( _ string: UnsafePointer < CChar > ? ) {
2936 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
3043 self . init ( str, UTF8 . _nullCodeUnitOffset ( in: str) , . init( ) )
44+ #endif
3145 } else {
3246 self . init ( )
3347 }
You can’t perform that action at this time.
0 commit comments