-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
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