Skip to content

Add support for std::ostream in Swift #83155

@maddyadams

Description

@maddyadams

Motivation

C++ types often write operators using std::ostream to make it easy to print the contents of a type (similar to CustomStringConvertible in Swift). Currently, these operators can't be used in Swift because std::ostream isn't imported into Swift

Proposed solution

Import std::ostream into Swift

Alternatives considered

It could be interesting for the compiler to map functions of the form std::ostream& operator<<(std::ostream& o, const MyObject& obj); to public var description: String on MyObject without importing std::ostream. However, there are ways to use std::ostream that this wouldn't capture (e.g. a formatting function that takes an argument that configures how things are formatted), and those functions wouldn't be available in Swift unless std::ostream was available as well

Additional information

rdar://149558586

Metadata

Metadata

Assignees

Labels

c++ interopFeature: Interoperability with C++featureA feature request or implementation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions