Skip to main content

Mojo module

traits

Compile-time meta functions for checking trait conformance across variadic type lists.

comptime values

AllCopyable

comptime AllCopyable[*Ts: AnyType] = #kgen.variadic.reduce(Ts, base=True, reducer=[PrevV: Variadic[Bool], VA: Variadic[AnyType], idx: __mlir_type.index] PrevV[0] if Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::value::Copyable & std::builtin::value::Movable)) else Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::value::Copyable & std::builtin::value::Movable)))[0]

Evaluates to True if all types in Ts conform to Copyable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Copyable.

AllDefaultable

comptime AllDefaultable[*Ts: AnyType] = #kgen.variadic.reduce(Ts, base=True, reducer=[PrevV: Variadic[Bool], VA: Variadic[AnyType], idx: __mlir_type.index] PrevV[0] if Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::anytype::ImplicitlyDestructible & std::builtin::value::Defaultable)) else Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::anytype::ImplicitlyDestructible & std::builtin::value::Defaultable)))[0]

Evaluates to True if all types in Ts conform to Defaultable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Defaultable.

AllEquatable

comptime AllEquatable[*Ts: AnyType] = #kgen.variadic.reduce(Ts, base=True, reducer=[PrevV: Variadic[Bool], VA: Variadic[AnyType], idx: __mlir_type.index] PrevV[0] if Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::anytype::ImplicitlyDestructible & std::builtin::comparable::Equatable)) else Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::anytype::ImplicitlyDestructible & std::builtin::comparable::Equatable)))[0]

Evaluates to True if all types in Ts conform to Equatable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Equatable.

AllHashable

comptime AllHashable[*Ts: AnyType] = #kgen.variadic.reduce(Ts, base=True, reducer=[PrevV: Variadic[Bool], VA: Variadic[AnyType], idx: __mlir_type.index] PrevV[0] if Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::hashlib::hash::Hashable)) else Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::hashlib::hash::Hashable)))[0]

Evaluates to True if all types in Ts conform to Hashable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Hashable.

AllImplicitlyCopyable

comptime AllImplicitlyCopyable[*Ts: AnyType] = #kgen.variadic.reduce(Ts, base=True, reducer=[PrevV: Variadic[Bool], VA: Variadic[AnyType], idx: __mlir_type.index] PrevV[0] if Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::anytype::ImplicitlyDestructible & std::builtin::value::Copyable & std::builtin::value::ImplicitlyCopyable & std::builtin::value::Movable)) else Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::anytype::ImplicitlyDestructible & std::builtin::value::Copyable & std::builtin::value::ImplicitlyCopyable & std::builtin::value::Movable)))[0]

Evaluates to True if all types in Ts conform to ImplicitlyCopyable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to ImplicitlyCopyable.

AllImplicitlyDestructible

comptime AllImplicitlyDestructible[*Ts: AnyType] = #kgen.variadic.reduce(Ts, base=True, reducer=[PrevV: Variadic[Bool], VA: Variadic[AnyType], idx: __mlir_type.index] PrevV[0] if Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::anytype::ImplicitlyDestructible)) else Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::anytype::ImplicitlyDestructible)))[0]

Evaluates to True if all types in Ts conform to ImplicitlyDestructible, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to ImplicitlyDestructible.

AllMovable

comptime AllMovable[*Ts: AnyType] = #kgen.variadic.reduce(Ts, base=True, reducer=[PrevV: Variadic[Bool], VA: Variadic[AnyType], idx: __mlir_type.index] PrevV[0] if Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::value::Movable)) else Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::value::Movable)))[0]

Evaluates to True if all types in Ts conform to Movable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Movable.

AllWritable

comptime AllWritable[*Ts: AnyType] = #kgen.variadic.reduce(Ts, base=True, reducer=[PrevV: Variadic[Bool], VA: Variadic[AnyType], idx: __mlir_type.index] PrevV[0] if Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::anytype::ImplicitlyDestructible & std::format::__init__::Writable)) else Bool(conforms_to(VA[idx], std::builtin::anytype::AnyType & std::builtin::anytype::ImplicitlyDestructible & std::format::__init__::Writable)))[0]

Evaluates to True if all types in Ts conform to Writable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Writable.

Was this page helpful?