// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
// swift-module-flags: -target arm64_32-apple-watchos4.0 -enable-objc-interop -enable-library-evolution -static -swift-version 5 -O -library-level api -enforce-exclusivity=unchecked -enable-experimental-cxx-interop -module-name Cxx
// swift-module-flags-ignorable: -user-module-version 5.9.2.2.56 -enable-lexical-lifetimes=false -target-min-inlining-version min
import Swift
#if compiler(>=5.3) && $PrimaryAssociatedTypes2
public protocol CxxConvertibleToCollection<Element> {
  associatedtype Element where Self.Element == Self.RawIterator.Pointee
  associatedtype RawIterator : Cxx.UnsafeCxxInputIterator
  func __beginUnsafe() -> Self.RawIterator
  func __endUnsafe() -> Self.RawIterator
}
#else
public protocol CxxConvertibleToCollection {
  associatedtype Element where Self.Element == Self.RawIterator.Pointee
  associatedtype RawIterator : Cxx.UnsafeCxxInputIterator
  func __beginUnsafe() -> Self.RawIterator
  func __endUnsafe() -> Self.RawIterator
}
#endif
extension Cxx.CxxConvertibleToCollection {
  @inlinable public func forEach(_ body: (Self.RawIterator.Pointee) throws -> Swift.Void) rethrows {
    var rawIterator = __beginUnsafe()
    let endIterator = __endUnsafe()
    while rawIterator != endIterator {
      try body(rawIterator.pointee)
      rawIterator = rawIterator.successor()
    }
  }
}
extension Cxx.CxxConvertibleToCollection where Self : Swift.Sequence {
  @inlinable public func forEach(_ body: (Self.Element) throws -> Swift.Void) rethrows {
    for element in self {
      try body(element)
    }
  }
}
extension Swift.RangeReplaceableCollection {
  @inlinable public init<C>(_ elements: __shared C) where C : Cxx.CxxConvertibleToCollection, Self.Element == C.Element {

    self.init()
    elements.forEach { self.append($0) }
  }
}
extension Swift.SetAlgebra {
  @inlinable public init<C>(_ elements: __shared C) where C : Cxx.CxxConvertibleToCollection, Self.Element == C.Element {

    self.init()
    elements.forEach { self.insert($0) }
  }
}
#if compiler(>=5.3) && $PrimaryAssociatedTypes2
public protocol CxxDictionary<Key, Value> {
  associatedtype Key where Self.Key == Self.RawIterator.Pointee.First
  associatedtype Value where Self.Value == Self.RawIterator.Pointee.Second
  associatedtype RawIterator : Cxx.UnsafeCxxInputIterator where Self.RawIterator.Pointee : Cxx.CxxPair
  func __findUnsafe(_ key: Self.Key) -> Self.RawIterator
  func __endUnsafe() -> Self.RawIterator
}
#else
public protocol CxxDictionary {
  associatedtype Key where Self.Key == Self.RawIterator.Pointee.First
  associatedtype Value where Self.Value == Self.RawIterator.Pointee.Second
  associatedtype RawIterator : Cxx.UnsafeCxxInputIterator where Self.RawIterator.Pointee : Cxx.CxxPair
  func __findUnsafe(_ key: Self.Key) -> Self.RawIterator
  func __endUnsafe() -> Self.RawIterator
}
#endif
extension Cxx.CxxDictionary {
  @inlinable public subscript(key: Self.Key) -> Self.Value? {
    get {
      let iter = __findUnsafe(key)
      guard iter != __endUnsafe() else {
        return nil
      }
      return iter.pointee.second
    }
  }
}
#if compiler(>=5.3) && $PrimaryAssociatedTypes2
public protocol CxxPair<First, Second> {
  associatedtype First
  associatedtype Second
  var first: Self.First { get }
  var second: Self.Second { get }
}
#else
public protocol CxxPair {
  associatedtype First
  associatedtype Second
  var first: Self.First { get }
  var second: Self.Second { get }
}
#endif
#if compiler(>=5.3) && $PrimaryAssociatedTypes2
public protocol CxxOptional<Wrapped> {
  associatedtype Wrapped
  func __convertToBool() -> Swift.Bool
  var pointee: Self.Wrapped { get }
}
#else
public protocol CxxOptional {
  associatedtype Wrapped
  func __convertToBool() -> Swift.Bool
  var pointee: Self.Wrapped { get }
}
#endif
extension Cxx.CxxOptional {
  @inlinable public var hasValue: Swift.Bool {
    get {
      return __convertToBool()
    }
  }
  @inlinable public var value: Self.Wrapped? {
    get {
      guard hasValue else { return nil }
      return pointee
    }
  }
}
extension Swift.Optional {
  @inlinable public init(fromCxx value: some CxxOptional<Wrapped>) {
    guard value.__convertToBool() else {
      self = nil
      return
    }
    self = value.pointee
  }
}
#if compiler(>=5.3) && $PrimaryAssociatedTypes2
public protocol CxxSet<Element> {
  associatedtype Element
  associatedtype Size : Swift.BinaryInteger
  associatedtype InsertionResult
  init()
  @discardableResult
  mutating func __insertUnsafe(_ element: Self.Element) -> Self.InsertionResult
  func count(_ element: Self.Element) -> Self.Size
}
#else
public protocol CxxSet {
  associatedtype Element
  associatedtype Size : Swift.BinaryInteger
  associatedtype InsertionResult
  init()
  @discardableResult
  mutating func __insertUnsafe(_ element: Self.Element) -> Self.InsertionResult
  func count(_ element: Self.Element) -> Self.Size
}
#endif
extension Cxx.CxxSet {
  @inlinable public init<S>(_ sequence: __shared S) where S : Swift.Sequence, Self.Element == S.Element {
    self.init()
    for item in sequence {
      self.__insertUnsafe(item)
    }
  }
  @inlinable public func contains(_ element: Self.Element) -> Swift.Bool {
    return count(element) > 0
  }
}
#if compiler(>=5.3) && $PrimaryAssociatedTypes2
public protocol CxxUniqueSet<Element> : Cxx.CxxSet where Self.InsertionResult : Cxx.CxxPair, Self.InsertionResult.Second == Swift.Bool {
  override associatedtype Element
  override associatedtype Size
  associatedtype RawMutableIterator : Cxx.UnsafeCxxInputIterator where Self.Element == Self.RawMutableIterator.Pointee, Self.RawMutableIterator == Self.InsertionResult.First
  override associatedtype InsertionResult
}
#else
public protocol CxxUniqueSet : Cxx.CxxSet where Self.InsertionResult : Cxx.CxxPair, Self.InsertionResult.Second == Swift.Bool {
  override associatedtype Element
  override associatedtype Size
  associatedtype RawMutableIterator : Cxx.UnsafeCxxInputIterator where Self.Element == Self.RawMutableIterator.Pointee, Self.RawMutableIterator == Self.InsertionResult.First
  override associatedtype InsertionResult
}
#endif
extension Cxx.CxxUniqueSet {
  @discardableResult
  @inlinable public mutating func insert(_ newMember: Self.Element) -> (inserted: Swift.Bool, memberAfterInsert: Self.Element) {
    let insertionResult = self.__insertUnsafe(newMember)
    let rawIterator: RawMutableIterator = insertionResult.first
    let inserted: Bool = insertionResult.second
    return (inserted, rawIterator.pointee)
  }
}
#if compiler(>=5.3) && $PrimaryAssociatedTypes2
public protocol CxxRandomAccessCollection<Element> : Cxx.CxxSequence, Swift.RandomAccessCollection where Self.RawIterator : Cxx.UnsafeCxxRandomAccessIterator {
  override associatedtype Element
  override associatedtype RawIterator
  override associatedtype Iterator = Cxx.CxxIterator<Self>
  override associatedtype Index = Swift.Int
  override associatedtype Indices = Swift.Range<Swift.Int>
  override associatedtype SubSequence = Swift.Slice<Self>
}
#else
public protocol CxxRandomAccessCollection : Cxx.CxxSequence, Swift.RandomAccessCollection where Self.RawIterator : Cxx.UnsafeCxxRandomAccessIterator {
  override associatedtype Element
  override associatedtype RawIterator
  override associatedtype Iterator = Cxx.CxxIterator<Self>
  override associatedtype Index = Swift.Int
  override associatedtype Indices = Swift.Range<Swift.Int>
  override associatedtype SubSequence = Swift.Slice<Self>
}
#endif
extension Cxx.CxxRandomAccessCollection {
  @inlinable public var startIndex: Swift.Int {
    get {
    return 0
  }
  }
  @inlinable public var endIndex: Swift.Int {
    get {
    return count
  }
  }
  @inlinable public var count: Swift.Int {
    get {
    return Int(__endUnsafe() - __beginUnsafe())
  }
  }
  @inlinable public subscript(index: Swift.Int) -> Self.Element {
    _read {
      // Not using CxxIterator here to avoid making a copy of the collection.
      var rawIterator = __beginUnsafe()
      rawIterator += RawIterator.Distance(index)
      yield rawIterator.pointee
    }
  }
}
#if compiler(>=5.3) && $PrimaryAssociatedTypes2
public protocol CxxSequence<Element> : Cxx.CxxConvertibleToCollection, Swift.Sequence {
  override associatedtype Element
  override associatedtype RawIterator
  override associatedtype Iterator = Cxx.CxxIterator<Self>
  mutating func __beginUnsafe() -> Self.RawIterator
  mutating func __endUnsafe() -> Self.RawIterator
}
#else
public protocol CxxSequence : Cxx.CxxConvertibleToCollection, Swift.Sequence {
  override associatedtype Element
  override associatedtype RawIterator
  override associatedtype Iterator = Cxx.CxxIterator<Self>
  mutating func __beginUnsafe() -> Self.RawIterator
  mutating func __endUnsafe() -> Self.RawIterator
}
#endif
@usableFromInline
final internal class CxxSequenceBox<T> where T : Cxx.CxxSequence {
  @usableFromInline
  final internal var sequence: T
  @usableFromInline
  internal init(_ sequence: __shared T)
  @objc @usableFromInline
  deinit
}
@frozen public struct CxxIterator<T> : Swift.IteratorProtocol where T : Cxx.CxxSequence {
  public typealias Element = T.RawIterator.Pointee
  @usableFromInline
  internal let sequence: Cxx.CxxSequenceBox<T>
  @usableFromInline
  internal var rawIterator: T.RawIterator
  @usableFromInline
  internal let endIterator: T.RawIterator
  @inlinable public init(sequence: __shared T) {
    self.sequence = CxxSequenceBox<T>(sequence)
    self.rawIterator = self.sequence.sequence.__beginUnsafe()
    self.endIterator = self.sequence.sequence.__endUnsafe()
  }
  @inlinable public mutating func next() -> Cxx.CxxIterator<T>.Element? {
    if self.rawIterator == self.endIterator {
      return nil
    }
    let object = self.rawIterator.pointee
    self.rawIterator = self.rawIterator.successor()
    return object
  }
}
extension Cxx.CxxSequence {
  @inlinable public func makeIterator() -> Cxx.CxxIterator<Self> {
    return CxxIterator(sequence: self)
  }
}
public protocol UnsafeCxxInputIterator : Swift.Equatable {
  associatedtype Pointee
  var pointee: Self.Pointee { get }
  func successor() -> Self
}
extension Swift.UnsafePointer : Cxx.UnsafeCxxInputIterator {
}
extension Swift.UnsafeMutablePointer : Cxx.UnsafeCxxInputIterator {
}
extension Swift.Optional : Cxx.UnsafeCxxInputIterator where Wrapped : Cxx.UnsafeCxxInputIterator {
  public typealias Pointee = Wrapped.Pointee
  @inlinable public var pointee: Swift.Optional<Wrapped>.Pointee {
    get {
    if let value = self {
      return value.pointee
    }
    fatalError("Could not dereference nullptr")
  }
  }
  @inlinable public func successor() -> Swift.Optional<Wrapped> {
    if let value = self {
      return value.successor()
    }
    fatalError("Could not increment nullptr")
  }
}
public protocol UnsafeCxxRandomAccessIterator : Cxx.UnsafeCxxInputIterator {
  associatedtype Distance : Swift.BinaryInteger
  static func - (lhs: Self, rhs: Self) -> Self.Distance
  static func += (lhs: inout Self, rhs: Self.Distance)
}
extension Swift.UnsafePointer : Cxx.UnsafeCxxRandomAccessIterator {
}
extension Swift.UnsafeMutablePointer : Cxx.UnsafeCxxRandomAccessIterator {
}
