プロトコル


Copyable


値を暗黙的または明示的にコピーできる型。


iOS 8.0+ iPadOS 8.0+ Mac Catalyst 13.0+ macOS 10.10+

tvOS 9.0+ VisionOS 1.0+ WatchOS 2.0+


protocol Copyable






概観


このプロトコルに準拠するということは、型の値がコピー可能であることを意味します。このプロトコルには必須のメソッドやプロパティはありません。通常、Copyable への準拠を明示的に記述する必要はありません。以下の箇所では暗黙的に Copyable への準拠が含まれています。


  • 構造体宣言 (コピー不可能な格納プロパティを持つ場合を除く)

  • 列挙型宣言 (関連する値がコピー不可能なケースを持つ場合を除く)

  • クラス宣言

  • アクター宣言

  • プロトコル宣言

  • 関連型宣言

  • プロトコル拡張における Self

  • 拡張において、拡張される型のジェネリック (汎用) パラメータ

  • クラスまたはアクターは、コピー不可能な格納プロパティを含むことができますが、それ自体はコピー可能です。クラスとアクターは、参照を保持および解放することによってコピーされます。


    ジェネリック (汎用) 型パラメータを含む宣言では、各ジェネリック型パラメータの要件リストに暗黙的に Copyable が含まれます。コピー可能な型のメタタイプとタプルも、ボックス化されたプロトコル型と同様に暗黙的にコピー可能です。例えば、以下の宣言のペアはすべて同等です。


    struct MyStructure { }
    struct MyStructere: Copyable { }
    
    protocol MyProtocol { }
    protocol MyProtocol: Copyable { }
    
    protocol AnotherProtocol {
        associatedtype MyType
        associatedtype MyType: Copyable
    }
    
    func genericFunction<T>(t: T) { }
    func genericFunction<T>(t: T) where T: Copyable { }
    
    let x: any MyProtocol
    let x: any MyProtocol & Copyable
    

    Copyable への暗黙的な準拠を抑制するには、~Copyable と記述して下さい。例えば、上記の例ではコピー可能な型のみが MyProtocol に準拠しますが、以下の例ではコピー可能な型とコピー不可能な型の両方が NoRequirements に準拠します。


    protocol NoRequirements: ~Copyable { }

    Copyable プロトコルの拡張は許可されません。





    関連


    準拠型


    Anchor

    AnyBidirectionalCollection

    ElementCopyable かつ Escapable に準拠している場合に準拠します。


    AnyCollection

    ElementCopyable かつ Escapable に準拠している場合に準拠します。


    AnyHashable

    AnyIndex

    AnyIterator

    ElementCopyable かつ Escapable に準拠している場合に準拠します。


    AnyKeyPath

    AnyRandomAccessCollection

    ElementCopyable かつ Escapable に準拠している場合に準拠します。


    AnyRegexOutput

    AnySequence

    ElementCopyable かつ Escapable に準拠している場合に準拠します。


    Array

    ElementCopyable かつ Escapable に準拠している場合に準拠します。


    ArraySlice

    ElementCopyable かつ Escapable に準拠している場合に準拠します。


    AsyncCompactMapSequence

    BaseAsyncSequence に準拠し, ElementOfResultCopyable に準拠し, ElementOfResultEscapable に準拠している場合に準拠します。


    AsyncDropFirstSequence

    BaseAsyncSequence に準拠している場合に準拠します。


    AsyncDropWhileSequence

    BaseAsyncSequence に準拠している場合に準拠します。


    AsyncFilterSequence

    BaseAsyncSequence に準拠している場合に準拠します。


    AsyncFlatMapSequence

    BaseAsyncSequence に準拠し、SegmentOfResultAsyncSequence に準拠している場合に準拠します。


    AsyncMapSequence

    BaseAsyncSequence に準拠し, TransformedCopyable に準拠し, TransformedEscapable に準拠している場合に準拠します。


    AsyncPrefixSequence

    BaseAsyncSequence に準拠している場合に準拠します。


    AsyncPrefixWhileSequence

    BaseAsyncSequence に準拠している場合に準拠します。


    AsyncStream

    ElementCopyableEscapable に準拠している場合に準拠します。


    AsyncStream.Continuation

    ElementCopyableEscapable に準拠している場合に準拠します。


    AsyncStream.Continuation.Termination

    ElementCopyableEscapable に準拠している場合に準拠します。


    AsyncThrowingCompactMapSequence

    BaseAsyncSequence に準拠し, ElementOfResultCopyable に準拠し, ElementOfResultEscapable に準拠している場合に準拠します。


    AsyncThrowingDropWhileSequence

    BaseAsyncSequence に準拠している場合準拠します。


    AsyncThrowingFilterSequence

    BaseAsyncSequence に準拠している場合準拠します。


    AsyncThrowingFlatMapSequence

    BaseAsyncSequence に準拠し SegmentOfResultAsyncSequence に準拠している場合準拠します。


    AsyncThrowingMapSequence

    BaseAsyncSequence に準拠し, TransformedCopyable に準拠し, TransformedEscapable に準拠している場合準拠します。


    AsyncThrowingPrefixWhileSequence

    BaseAsyncSequence に準拠している場合準拠します。


    AsyncThrowingStream

    ElementCopyable に準拠し, ElementEscapable に準拠し, FailureError に準拠している場合準拠します。


    AsyncThrowingStream.Continuation

    ElementCopyable に準拠し, ElementEscapable に準拠し, FailureError に準拠している場合準拠します。


    AtomicLoadOrdering

    AtomicStoreOrdering

    AtomicUpdateOrdering

    AutoreleasingUnsafeMutablePointer

    PointeeCopyableEscapable に準拠している場合準拠します。


    Bool

    CVaListPointer

    Capture

    OutputCopyableEscapable に準拠している場合準拠します。


    Character

    CharacterClass

    ChoiceOf

    OutputCopyableEscapable に準拠している場合準拠します。


    ClosedRange

    BoundComparable に準拠している場合準拠します。


    ClosedRange.Index

    BoundStrideable に準拠し Bound.StrideSignedInteger に準拠している場合準拠します。


    CollectionDifference

    ChangeElementCopyableEscapable に準拠している場合準拠します。


    CollectionDifference.Change

    ChangeElementEquatable に準拠している場合準拠します。


    CollectionDifference.Index

    ChangeElementCopyableEscapable に準拠している場合準拠します。


    CollectionOfOne

    ElementCopyableEscapable に準拠している場合準拠します。


    CollectionOfOne.Iterator

    ElementCopyableEscapable に準拠している場合準拠します。


    ContiguousArray

    ElementEncodable に準拠している場合準拠します。


    ContinuousClock

    ContinuousClock.Instant

    DecodingError

    DefaultIndices

    ElementsCollection に準拠している場合準拠します。


    DefaultStringInterpolation

    Dictionary

    KeyEncodable に準拠し, KeyHashable に準拠し, ValueEncodable に準拠している場合準拠します。


    Dictionary.Index

    KeyHashable に準拠し, ValueCopyable に準拠し, ValueEscapable に準拠している場合準拠します。


    Dictionary.Iterator

    KeyHashable に準拠し, ValueCopyable に準拠し, ValueEscapable に準拠している場合準拠します。


    Dictionary.Keys

    KeyHashable に準拠し, ValueCopyable に準拠し, ValueEscapable に準拠している場合準拠します。


    Dictionary.Values

    KeyHashable に準拠し, ValueCopyable に準拠し, ValueEscapable に準拠している場合準拠します。


    DiscardingTaskGroup

    DiscontiguousSlice

    BaseCollection に準拠し Base.ElementEquatable に準拠している場合準拠します。


    DiscontiguousSlice.Index

    BaseCollection に準拠している場合準拠します。


    DispatchMainExecutor

    Double

    DropFirstSequence

    BaseSequence に準拠している場合準拠します。


    DropWhileSequence

    BaseSequence に準拠している場合準拠します。


    DropWhileSequence.Iterator

    BaseSequence に準拠している場合準拠します。


    Duration

    Duration.TimeFormatStyle

    Duration.TimeFormatStyle.Attributed

    Duration.UnitsFormatStyle

    Duration.UnitsFormatStyle.Attributed

    EmptyCollection

    ElementCopyableEscapable に準拠している場合準拠します。


    EmptyCollection.Iterator

    ElementCopyableEscapable に準拠している場合準拠します。


    EncodingError

    EnumeratedSequence

    BaseSequence に準拠している場合準拠します。


    EnumeratedSequence.Index

    BaseCollection に準拠している場合準拠します。


    EnumeratedSequence.Iterator

    BaseSequence に準拠している場合準拠します。


    ExecuteDistributedTargetError.ErrorCode

    ExecutorJob.Kind

    FlattenSequence

    BaseSequence に準拠し Base.ElementSequenceに準拠している場合準拠します。


    FlattenSequence.Index

    BaseCollection に準拠し Base.ElementCollection に準拠している場合準拠します。


    FlattenSequence.Iterator

    BaseSequence に準拠し Base.ElementSequenceに準拠している場合準拠します。


    Float

    Float16

    Float80

    FloatingPointClassification

    FloatingPointRoundingRule

    FloatingPointSign

    Hasher

    IndexingIterator

    ElementsCollection に準拠している場合準拠します。


    InlineArray

    ElementCopyableEscapable に準拠している場合準拠します。


    Int

    Int.Words

    Int128

    Int16

    Int16.Words

    Int32

    Int32.Words

    Int64

    Int64.Words

    Int8

    Int8.Words

    IteratorSequence

    BaseIteratorProtocol に準拠している場合準拠します。


    JobPriority

    JoinedSequence

    BaseSequence に準拠し Base.ElementSequence に準拠している場合準拠します。


    JoinedSequence.Iterator

    BaseSequence に準拠し Base.ElementSequence に準拠している場合準拠します。


    KeyValuePairs

    KeyCopyable に準拠し, KeyEscapable に準拠し, ValueCopyable に準拠し, ValueEscapable に準拠している場合準拠します。


    LazyDropWhileSequence

    BaseSequence に準拠している場合準拠します。


    LazyDropWhileSequence.Iterator

    BaseSequence に準拠している場合準拠します。


    LazyFilterSequence

    BaseSequence に準拠している場合準拠します。


    LazyFilterSequence.Iterator

    BaseSequence に準拠している場合準拠します。


    LazyMapSequence

    BaseSequence に準拠し, ElementCopyable に準拠し, ElementEscapable に準拠している場合準拠します。


    LazyMapSequence.Iterator

    BaseSequence に準拠し, ElementCopyable に準拠し, ElementEscapable に準拠している場合準拠します。


    LazyPrefixWhileSequence

    BaseSequence に準拠している場合準拠します。


    LazyPrefixWhileSequence.Index

    BaseCollection に準拠している場合準拠します。


    LazyPrefixWhileSequence.Iterator

    BaseSequence に準拠している場合準拠します。


    LazySequence

    BaseCollection に準拠している場合準拠します。


    Local

    OutpuCopyableEscapable に準拠している場合準拠します。


    Lookahead

    OutpuCopyableEscapable に準拠している場合準拠します。


    ManagedBufferPointer

    HeaderCopyable に準拠し, HeaderEscapable に準拠し, ElementEscapable に準拠している場合準拠します。


    Mirror

    Mirror.DisplayStyle

    NegativeLookahead

    OutputCopyableEscapable に準拠している場合準拠します。


    Never

    ObjectIdentifier

    ObservationRegistrar

    OneOrMore

    OutputCopyableEscapable に準拠している場合準拠します。


    OpaquePointer

    Optional

    WrappedEncodable に準拠している場合準拠します。


    Optional.Publisher

    WrappedEquatable に準拠している場合準拠します。


    Optionally

    OutputCopyableEscapable に準拠している場合準拠します。


    PartialRangeFrom

    BoundComparable に準拠している場合準拠します。


    PartialRangeThrough

    BoundComparable に準拠している場合準拠します。


    PartialRangeUpTo

    BoundComparable に準拠している場合準拠します。


    PrefixSequence

    BaseSequence に準拠している場合準拠します。


    PrefixSequence.Iterator

    BaseSequence に準拠している場合準拠します。


    Range

    BoundStrideable に準拠し Bound.StrideSignedInteger に準拠している場合準拠します。


    RangeSet

    BoundComparable に準拠している場合準拠します。


    RangeSet.Ranges

    BoundComparable に準拠している場合準拠します。


    Repeat

    OutputCopyableEscapable に準拠している場合準拠します。


    Repeated

    ElementCopyableEscapable に準拠している場合準拠します。


    Result

    SuccessCopyable に準拠し FailureError に準拠している場合準拠します。


    Result.Publisher

    SuccessEquatable に準拠し, FailureEquatable に準拠し, FailureError に準拠している場合準拠します。


    ReversedCollection

    BaseBidirectionalCollectionLazySequenceProtocol に準拠している場合準拠します。


    ReversedCollection.Index

    BaseBidirectionalCollection に準拠している場合準拠します。


    ReversedCollection.Iterator

    BaseBidirectionalCollection に準拠している場合準拠します。


    SIMD16

    ScalarSIMDScalar に準拠している場合準拠します。


    SIMD2

    ScalarSIMDScalar に準拠している場合準拠します。


    SIMD3

    ScalarSIMDScalar に準拠している場合準拠します。


    SIMD32

    ScalarSIMDScalar に準拠している場合準拠します。


    SIMD4

    ScalarSIMDScalar に準拠している場合準拠します。


    SIMD64

    ScalarSIMDScalar に準拠している場合準拠します。


    SIMD8

    ScalarSIMDScalar に準拠している場合準拠します。


    Set

    ElementEncodableHashable に準拠している場合準拠します。


    Set.Index

    ElementHashable に準拠している場合準拠します。


    Set.Iterator

    ElementHashable に準拠している場合準拠します。


    Slice

    BaseCollectionLazySequenceProtocol に準拠している場合準拠します。


    StaticBigInt

    StaticString

    StrideThrough

    ElementStrideable に準拠している場合準拠します。


    StrideThroughIterator

    ElementStrideable に準拠している場合準拠します。


    StrideTo

    ElementStrideable に準拠している場合準拠します。


    StrideToIterator

    ElementStrideable に準拠している場合準拠します。


    String

    String.Encoding

    String.Index

    String.IntentInputOptions.CapitalizationType

    String.IntentInputOptions.KeyboardType

    String.LocalizationValue

    String.UTF16View

    String.UTF8View

    String.UnicodeScalarView

    Substring

    Substring.UTF16View

    Substring.UTF8View

    Substring.UnicodeScalarView

    SuspendingClock

    SuspendingClock.Instant

    SystemRandomNumberGenerator

    Task

    SuccessCopyable に準拠し, SuccessEscapable に準拠し, SuccessSendable に準拠し, FailureError に準拠している場合準拠します。


    TaskGroup

    ChildTaskResultCopyable,Escapable,および Sendable に準拠している場合準拠します。


    TaskPriority

    ThrowingDiscardingTaskGroup

    FailureError に準拠している場合準拠します。


    ThrowingTaskGroup

    ChildTaskResultCopyable に準拠し, ChildTaskResultEscapable に準拠し, ChildTaskResultSendable に準拠し, FailureError に準拠している場合準拠します。


    TryCapture

    OutputCopyableEscapable に準拠している場合準拠します。


    UInt

    UInt.Words

    UInt128

    UInt128.Words

    UInt16

    UInt16.Words

    UInt32

    UInt32.Words

    UInt64

    UInt64.Words

    UInt8

    UInt8.Words

    UTF8Span.UnicodeScalarIterator

    UnboundedRange_

    Unicode.ASCII

    Unicode.ASCII.Parser

    Unicode.GeneralCategory

    Unicode.NumericType

    Unicode.Scalar

    Unicode.Scalar.UTF16View

    Unicode.Scalar.UTF8View

    Unicode.UTF16

    Unicode.UTF16.ForwardParser

    Unicode.UTF16.ReverseParser

    Unicode.UTF32

    Unicode.UTF32.Parser

    Unicode.UTF8

    Unicode.UTF8.ForwardParser

    Unicode.UTF8.ReverseParser

    Unicode.UTF8.ValidationError

    Unicode.UTF8.ValidationError.Kind

    UnicodeDecodingResult

    Unmanaged

    InstanceCopyableEscapable に準拠している場合準拠します。


    UnownedJob

    UnownedSerialExecutor

    UnownedTaskExecutor

    UnsafeBufferPointer

    ElementEscapable に準拠している場合準拠します。


    UnsafeBufferPointer.Iterator

    ElementCopyableEscapable に準拠している場合準拠します。


    UnsafeContinuation

    TCopyable に準拠し, TEscapable に準拠し, EError に準拠している場合準拠します。


    UnsafeCurrentTask

    UnsafeMutableBufferPointer

    ElementEscapable に準拠している場合準拠します。


    UnsafeMutablePointer

    PointeeEscapable に準拠している場合準拠します。


    UnsafeMutableRawBufferPointer

    UnsafeMutableRawPointer

    UnsafePointer

    PointeeEscapable に準拠している場合準拠します。


    UnsafeRawBufferPointer

    UnsafeRawBufferPointer.Iterator

    UnsafeRawPointer

    WordPair

    ZeroOrMore

    OutputCopyableEscapable に準拠している場合準拠します。


    Zip2Sequence

    Sequence1Sequence に準拠し Sequence2Sequence に準拠している場合準拠します。


    Zip2Sequence.Iterator

    Sequence1Sequence に準拠し Sequence2Sequence に準拠している場合準拠します。





    以下も見よ


    コピーする

    protocol BitwiseCopyable














    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ












    トップへ