@@ -315,7 +315,10 @@ constructor, Swift will use it when a value of such type is copied in
315
315
Swift. And if the C++ type has a destructor, Swift will call the destructor when
316
316
a Swift value of such type is destroyed.
317
317
318
- C++ structures and classes with a deleted copy constructor are represented as non-copyable Swift types (` ~Copyable ` ).
318
+ C++ structures and classes with a deleted copy constructor are represented as
319
+ non-copyable Swift types (` ~Copyable ` ). If a C++ type has a valid copy
320
+ constructor, it is still possible to make it non-copyable in Swift by annotating
321
+ it with a ` SWIFT_NONCOPYABLE ` macro.
319
322
320
323
Some C++ types are always passed around using a pointer or a reference in C++.
321
324
As such it might not make sense to map them to value types in Swift. These
@@ -418,12 +421,9 @@ of better API usability Swift still assumes that such functions do not
418
421
mutate the object. You should avoid calling constant member functions
419
422
that mutate ` mutable ` fields from Swift, unless they're explicitly annotated with a ` SWIFT_MUTATING ` macro.
420
423
421
- > Swift 5.9 will ship with a ` SWIFT_MUTATING ` customization macro. However, it's not
422
- > yet available in a downloadable Swift 5.9 toolchain. This macro will
423
- > allow you to explicitly annotate constant member functions that do mutate the
424
- > object. Such functions with then become ` mutating ` methods in Swift. The
425
- > following [ GitHub issue] ( https://github.com/swiftlang/swift/issues/66322 )
426
- > tracks the status of ` SWIFT_MUTATING ` support in Swift.
424
+ The ` SWIFT_MUTATING ` macro allows you to explicitly annotate constant member
425
+ functions that do mutate the object. Such functions then become ` mutating `
426
+ methods in Swift.
427
427
428
428
#### Member Functions Returning References Are Unsafe by Default
429
429
@@ -1969,12 +1969,26 @@ that are outlined in the documentation above.
1969
1969
| ` SWIFT_SHARED_REFERENCE ` | [ Shared Reference Types] ( #shared-reference-types ) |
1970
1970
| ` SWIFT_UNSAFE_REFERENCE ` | [ Unsafe Reference Types] ( #unsafe-reference-types ) |
1971
1971
| ` SWIFT_RETURNS_INDEPENDENT_VALUE ` | [ Annotating Methods Returning Independent References or Views] ( #annotating-methods-returning-independent-references-or-views ) |
1972
+ | ` SWIFT_MUTATING ` | [ Constant Member Functions Must Not Mutate the Object] ( #constant-member-functions-must-not-mutate-the-object ) |
1973
+ | ` SWIFT_NONCOPYABLE ` | [ C++ Structures and Classes are Value Types by Default] ( #c-structures-and-classes-are-value-types-by-default ) |
1972
1974
| ` SWIFT_SELF_CONTAINED ` | [ Annotating C++ Structures or Classes as Self Contained] ( #annotating-c-structures-or-classes-as-self-contained ) |
1973
1975
1974
1976
## Document Revision History
1975
1977
1976
1978
This section lists the recent changes made to this reference guide.
1977
1979
1980
+ ** 2024-08-12**
1981
+
1982
+ - Added several customization macros from ` <swift/bridging> ` to the list.
1983
+
1984
+ ** 2024-06-11**
1985
+
1986
+ - Non-copyable C++ types are now available in Swift.
1987
+
1988
+ ** 2024-03-26**
1989
+
1990
+ - Updated the status of C++ templated operator support in Swift.
1991
+
1978
1992
** 2023-06-05**
1979
1993
1980
1994
- Published the initial version of the guide that describes how to mix Swift and C++.
0 commit comments