encyclopegia.org

union type

In computer science, a union is a value that may have any of multiple representations or formats within the same area of memory, or a variable that may hold such a data structure. Some programming languages support a union type for such a data type. In other words, a union type specifies the permitted types that may be stored in its instances, e.g., float and int . In contrast with a record, which could be defined to contain both a float and an integer, a union can hold only one at a time. A union can be pictured as a chunk of memory that is used to store variables of different data types. Once a new value is assigned to a field, the existing data is overwritten with the new data. The memory area storing the value has no intrinsic type (other than just bytes or words of memory), but the value can be treated as one of several abstract data types, having the type of the value that was last written to the memory area. In type theory, a union has a sum type; this corresponds to disjoint union in mathematics. Depending on the language and type, a union value may be used in some operations, such as assignment and comparison for equality, without knowing its specific type. Other operations may require that knowledge, either by some external information, or by the use of a tagged union.

In computer science, a union is a value that may have any of multiple representations or formats within the same area of memory, or a variable that may hold such a data structure. Some programming languages support a union type for such a data type. In other words, a union type specifies the permitted types that may be stored in its instances, e.g., float and int . In contrast with a record, which could be defined to contain both a float and an integer, a union can hold only one at a time. A union can be pictured as a chunk of memory that is used to store variables of different data types. Once a new value is assigned to a field, the existing data is overwritten with the new data. The memory area storing the value has no intrinsic type (other than just bytes or words of memory), but the value can be treated as one of several abstract data types, having the type of the value that was last written to the memory area. In type theory, a union has a sum type; this corresponds to disjoint union in mathematics. Depending on the language and type, a union value may be used in some operations, such as assignment and comparison for equality, without knowing its specific type. Other operations may require that knowledge, either by some external information, or by the use of a tagged union. ==Untagged unions== Because of the limitations of their use, untagged unions are generally only provided in untyped languages or in a type-unsafe way (as in C). They have the advantage over simple tagged unions of not requiring space to store a data type tag. The name "union" stems from the type's formal definition. If a type is considered as the set of all values that that type can take on, a union type is simply the mathematical union of its constituting types, since it can take on any value any of its fields can. Also, because a mathematical union discards duplicates, if more than one field of the union can take on a single common value, it is impossible to tell from the value alone which field was last written. However, one useful programming function of unions is to map smaller data elements to larger ones for easier manipulation. A data structure consisting, for example, of 4 bytes and a 32-bit integer, can form a union with an unsigned 64-bit integer, and thus be more readily accessed for purposes of comparison etc. ==Unions in various programming languages== ===ALGOL 68=== ALGOL 68 has tagged unions, and uses a case clause to distinguish and extract the constituent type at runtime. A union containing another union is treated as the set of all its constituent possibilities, and if the context requires it a union is automatically coerced into the wider union. A union can explicitly contain no value, which can be distinguished at runtime. An example is: mode node = union (real, int, string, void); node n := "abc"; case n in (real r): print(("real:", r)), (int i): print(("int:", i)), (string s): print(("string:", s)), (void): print(("void:", "EMPTY")), out print(("?:", n)) esac The syntax of the C/C++ union type and the notion of casts was derived from ALGOL 68, though in an untagged form. ===C/C++=== In C and C++, untagged unions are expressed nearly exactly like structures (structs), except that each data member is located at the same memory address. The data members, as in structures, need not be primitive values, and in fact may be structures or even other unions. C++ (since C++11) also allows for a data member to be any type that has a full-fledged constructor/destructor and/or copy constructor, or a non-trivial copy assignment operator. For example, it is possible to have the standard C++ string as a member of a union. The primary use of a union is allowing access to a common location by different data types, for example hardware input/output access, bitfield and word sharing, or type punning. Unions can also provide low-level polymorphism. However, there is no checking of types, so it is up to the programmer to be sure that the proper fields are accessed in different contexts. The relevant field of a union variable is typically determined by the state of other variables, possibly in an enclosing struct. One common C programming idiom uses unions to perform what C++ calls a reinterpret_cast , by assigning to one field of a union and reading from another, as is done in code which depends on the raw representation of the values. A practical example is the method of computing square roots using the IEEE representation. This is not, however, a safe use of unions in general. ====Anonymous union==== In C++, C11, and as a non-standard extension in many compilers, unions can also be anonymous. Their data members do not need to be referenced, are instead accessed directly. They have some restrictions as opposed to traditional unions: in C11, they must be a member of another structure or union, and in C++, they can not have methods or access specifiers. Simply omitting the class-name portion of the syntax does not make a union an anonymous union. For a union to qualify as an anonymous union, the declaration must not declare an object. Example: union { float f; uint32_t d; // Assumes float is 32 bits wide }; f = 3.14f; printf("Hexadecimal representation of 3.14f: %x\n", d); Anonymous unions are also useful in C struct definitions to provide a sense of namespacing. ===COBOL=== In COBOL, union data items are defined in two ways. The first uses the (66 level) keyword, which effectively maps a second alphanumeric data item on top of the same memory location as a preceding data item. In the example code below, data item is defined as a group containing another group and a numeric data item. is defined as an alphanumeric data item that renames , treating the data bytes continued within it as character data. 01 PERSON-REC. 05 PERSON-NAME. 10 PERSON-NAME-LAST PIC X(12). 10 PERSON-NAME-FIRST PIC X(16). 10 PERSON-NAME-MID PIC X. 05 PERSON-ID PIC 9(9) PACKED-DECIMAL. 01 PERSON-DATA RENAMES PERSON-REC. The second way to define a union type is by using the keyword. In the example code below, data item is defined as a 2-byte binary integer containing a version number. A second data item is defined as a two-character alphanumeric variable. Since the second item is redefined over the first item, the two items share the same address in memory, and therefore share the same underlying data bytes. The first item interprets the two data bytes as a binary value, while the second item interprets the bytes as character values. 01 VERS-INFO. 05 VERS-NUM PIC S9(4) COMP. 05 VERS-BYTES PIC X(2) REDEFINES VERS-NUM ===Pascal=== In Pascal, there are two ways to create unions. One is the standard way through a variant record. The second is a nonstandard means of declaring a variable as absolute, meaning it is placed at the same memory location as another variable or at an absolute address. While all Pascal compilers support variant records, only some support absolute variables. For the purposes of this example, the following are all integer types: a byte consists of 8 bits, a word is 16 bits, and an integer is 32 bits. The following example shows the non-standard absolute form: var A: Integer; B: array[1..4] of Byte absolute A; C: Integer absolute 0; In the first example, each of the elements of the array B maps to one of the specific bytes of the variable A. In the second example, the variable C is assigned to the exact machine address 0. In the following example, a record has variants, some of which share the same location as others: type Shape = (Circle, Square, Triangle); Dimensions = record case Figure: Shape of Circle: (Diameter: real); Square: (Width: real); Triangle: (Side: real; Angle1, Angle2: 0..360) end; ===PL/I=== In PL/I the original term for a union was cell, which is still accepted as a synonym for union by several compilers. The union declaration is similar to the structure definition, where elements at the same level within the union declaration occupy the same storage. Elements of the union can be any data type, including structures and array. Here vers_num and vers_bytes occupy the same storage locations. 1 vers_info union, 5 vers_num fixed binary, 5 vers_bytes pic '(2)A'; An alternative to a union declaration is the DEFINED attribute, which allows alternative declarations of storage, however the data types of the base and defined variables must match. ===Rust=== Rust implements both tagged and untagged unions. In Rust, tagged unions are implemented using the keyword. Unlike enumerated types in most other languages, enum variants in Rust can contain additional data in the form of a tuple or struct, making them tagged unions rather than simple enumerated types. Rust also supports untagged unions using the keyword. The memory layout of unions in Rust is undefined by default, but a union with the attribute will be laid out in memory exactly like the equivalent union in C. Reading the fields of a union can only be done within an function or block, as the compiler cannot guarantee that the data in the union will be valid for the type of the field; if this is not the case, it will result in undefined behavior. ==Syntax and example== ===C=== In C, a simplified version of the syntax is: union { ; ; . . . ; } ; A structure can also be a member of a union, as the following example shows: union { struct { int a; float b; char c; } svar; int d; } uvar; This example defines a variable uvar as a union which contains two members, a structure named svar (which in turn contains three members), and an integer variable named d . Unions may occur within structures and arrays, and vice versa: define N 10000 struct { int flags; char *name; int utype; union { int ival; float fval; char *sval; } u; } symtab[N]; The number ival is referred to by symtab[i].u.ival and the string sval by symtab[i].u.sval . ===C++=== C++ supports unions like C, but they are difficult to use safely in C++. For the two main purposes of unions, idiomatic C++ has alternatives: Type punning via unions like union { uint32_t x; float y; } to map from a floating-point value to its binary representation as an integer can be done with std::bit_cast . reinterpret_cast cannot be used for this in most cases due to the strict aliasing rule. For non-POD types, unions require explicit construction and destruction, making them cumbersome to use safely. std::variant , introduced in C++17, acts as a tagged union, avoiding this complication. include include include include include uint32_t encode_float_as_binary(float f) noexcept { // return reinterpret_cast (f); // UB return std::bit_cast (f); } bool is_integral(std::variant & v) { if (int* _ = std::get_if (&v)) { return true; } else if (float* f = std::get_if (&v)) { return std::modff(*f, nullptr) == 0; } throw std::invalid_argument("Invalid variant input!"); } ===C#=== Until C# 15, there were no union types in C#. The closest way to emulate them was through records and pattern matching. namespace Wikipedia.Examples; using System; abstract record Shape; record Circle(double Radius) : Shape; record Rectangle(double Width, double Height) : Shape; public class Example { public static double Area(Shape s) => s switch { Circle c => Math.PI * c.Radius * c.Radius, Rectangle r => r.Width * r.Height, _ => throw new NotSupportedException() }; } They could also be closely simulated using low-level layout. The following demonstrates such a union, where the fields occupy the same memory, but is not type-safe. It is best used for interoperability, serialization, and unsafe manipulation. using System.Runtime.InteropServices; // closest to C union IntFloatUnion { int i; float f; }; [StructLayout(LayoutKind.Explicit)] struct IntFloatUnion { [FieldOffset(0)] public int IntValue; [FieldOffset(0)] public float FloatValue; } In C# 15, unions were introduced to the language, as can be demonstrated by the following: public record class Car(string Model); public record class Bicycle(string Model); public record class Bus(string Model); public union Vehicle(Car, Bicycle, Bus); Vehicle car = new Car("Tesla Model 3"); Console.WriteLine(car.Value); // Car { Model = Tesla Model 3 } Vehicle bike = new Bicycle("Giant Escape 3"); Console.WriteLine(bike.Value); // Bicycle { Model = Giant Escape 3 } Vehicle bus = new Bus("Volvo 9700"); Console.WriteLine(bus.Value); // Bus { Model = Volvo 9700 } Vehicle v = /* some vehicle here */; string model = v switch { Car c => c.Model, Bicycle bk => b.Model, Bus bs => bs.Model, }; The default value of a union is null , but if all types in the union are non-nullable, then a switch expression need not check for null . ===Java=== Union types do not exist in Java, although they can be somewhat emulated using interfaces. // "Shape" can be thought of as a union of "Circle", "Rectangle", // and other types that implement "Shape" // we can explicitly restrict what is in the union using a sealed interface sealed interface Shape permits Circle, Rectangle {} record Circle(double radius) implements Shape {} record Rectangle(double width, double height) implements Shape {} class Example { double area(Shape s) { return switch (s) { case Circle(double r) -> Math.PI * r * r; case Rectangle(double w, double h) -> w * h; }; } } A catch clause can declare a union of multiple exception types. This syntax resembles union type syntax in other languages, but does not actually introduce a new type. The effective type of the exception parameter is the most specific common supertype of the alternatives. The catch clause only catches exceptions of the declared types, no other subclasses of the common supertype. class FooException extends RuntimeException { String name() { return "Foo"; } } class BarException extends RuntimeException { String name() { return "Bar"; } } void main() { try { throw Math.random() ===PHP=== Union types were introduced in PHP 8.0. The values are implicitly "tagged" with a type by the language, and may be retrieved by "gettype()". class Example { private int|float $foo; public function squareAndAdd(float|int $bar): int|float { return $bar ** 2 + $this->foo; } } ===Python=== Support for typing was introduced in Python 3.5. The new syntax for union types were introduced in Python 3.10. from typing import Union class Example: foo: int = 0 # old style: def square_and_add(self, bar: Union[int, float]) -> Union[int, float]: return bar ** 2 + self.foo # new style: def square_and_add(self, bar: int | float) -> int | float: return bar ** 2 + self.foo ===TypeScript=== Union types are supported in TypeScript. When TypeScript code is transpiled to JavaScript, all type-related information is lost. This means that there is no one way to identify the type of a value at runtime as it appears in TypeScript. However, all JavaScript values are implicitly "tagged" with a type by the language, which may be retrieved using the typeof operator for primitive values and the instanceof operator for classes. Because JavaScript uses a dynamic type system, how operations such as addition or indexing will behave is determined at runtime based on the type of the value. This means if all members of a union type support a given operation, no additional work has to be done to perform said operation. function length(v: string | any[]) { // because both strings and arrays have a "length" property, we can use it without having to figure out the actual type of v. return v.length; } function containsTheLetterA(v: string | string[] | number) { // sometimes, it is important to know the exact type of a value. if (typeof v === "string") { return v.includes("a"); } else if (v instanceof Array) { // because v is an Array, we want to check if any element includes the letter A. return v.some((element) => element.includes("a")); } else { // because we know it isn't an array or string, it must be a number. // numbers don't ever contain the letter a. return false; } } ===Rust=== Tagged unions in Rust use the keyword, and can contain tuple and struct variants: enum Foo { Bar(i32), Baz { x: String, y: i32 }, } Untagged unions in Rust use the keyword: union Foo { bar: i32, baz: bool, } Reading from the fields of an untagged union results in undefined behavior if the data in the union is not valid as the type of the field, and thus requires an block: let x = Foo { bar: 10 }; let y = unsafe { x.bar }; // This will set y to 10, and does not result in undefined behavior. let z = unsafe { x.baz }; // This results in undefined behavior, as the value stored in x is not a valid bool. ==References== ==External links== boost::variant, a type-safe alternative to C++ unions MSDN: Classes, Structures & Unions, for examples and syntax differences, differences between union & structure Difference between struct and union in C++ de:Verbund (Datentyp)#Unions

References

  1. Unions - The Rust Reference · retrieved 2023-04-24 · rev 1375308881
    Cite this reference

    MLA "Unions - The Rust Reference." 2023-04-24. https://doc.rust-lang.org/reference/items/unions.html. Accessed 25 November 2026.

    Chicago "Unions - The Rust Reference." 2023-04-24. https://doc.rust-lang.org/reference/items/unions.html.

    APA encyclopegia.org. (2023). Unions - The Rust Reference. Retrieved November 25, 2026, from https://doc.rust-lang.org/reference/items/unions.html

  2. Explore union types in C# 15 · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "Explore union types in C# 15." Bill Wagner (2 April 2026). 2026-11-19. https://devblogs.microsoft.com/dotnet/csharp-15-union-types/. Accessed 25 November 2026.

    Chicago "Explore union types in C# 15." Bill Wagner (2 April 2026). 2026-11-19. https://devblogs.microsoft.com/dotnet/csharp-15-union-types/.

    APA Bill Wagner (2 April 2026). (2026). Explore union types in C# 15. Retrieved November 25, 2026, from https://devblogs.microsoft.com/dotnet/csharp-15-union-types/

  3. The Java Language Specification. Section 14.20: The try statement · retrieved 2026-04-21 · rev 1375308881
    Cite this reference

    MLA "The Java Language Specification. Section 14.20: The try statement." Gosling, James ; Joy, Bill ; Steele, Guy ; Bracha, Gilad ; Buckley, Alex; Smith, Daniel; Bierman, Gavin. 2026-04-21. https://en.wikipedia.org/wiki/James_Gosling. Accessed 25 November 2026.

    Chicago "The Java Language Specification. Section 14.20: The try statement." Gosling, James ; Joy, Bill ; Steele, Guy ; Bracha, Gilad ; Buckley, Alex; Smith, Daniel; Bierman, Gavin. 2026-04-21. https://en.wikipedia.org/wiki/James_Gosling.

    APA Gosling, James ; Joy, Bill ; Steele, Guy ; Bracha, Gilad ; Buckley, Alex; Smith, Daniel; Bierman, Gavin. (2026). The Java Language Specification. Section 14.20: The try statement. Retrieved November 25, 2026, from https://en.wikipedia.org/wiki/James_Gosling

  4. PHP 8.0: Union Types · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "PHP 8.0: Union Types." Karunaratne, Ayesh. 2026-11-19. https://php.watch/versions/8.0/union-types. Accessed 25 November 2026.

    Chicago "PHP 8.0: Union Types." Karunaratne, Ayesh. 2026-11-19. https://php.watch/versions/8.0/union-types.

    APA Karunaratne, Ayesh. (2026). PHP 8.0: Union Types. Retrieved November 25, 2026, from https://php.watch/versions/8.0/union-types

  5. typing — Support for type hints — Python 3.9.7 documentation · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "typing — Support for type hints — Python 3.9.7 documentation." "typing — Support for type hints — Python 3. 2026-11-19. https://docs.python.org/3/library/typing.html#typing.Union. Accessed 25 November 2026.

    Chicago "typing — Support for type hints — Python 3.9.7 documentation." "typing — Support for type hints — Python 3. 2026-11-19. https://docs.python.org/3/library/typing.html#typing.Union.

    APA "typing — Support for type hints — Python 3. (2026). typing — Support for type hints — Python 3.9.7 documentation. Retrieved November 25, 2026, from https://docs.python.org/3/library/typing.html#typing.Union

  6. PEP 604 -- Allow writing union types as X | Y · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "PEP 604 -- Allow writing union types as X | Y." 2026-11-19. https://www.python.org/dev/peps/pep-0604/. Accessed 25 November 2026.

    Chicago "PEP 604 -- Allow writing union types as X | Y." 2026-11-19. https://www.python.org/dev/peps/pep-0604/.

    APA encyclopegia.org. (2026). PEP 604 -- Allow writing union types as X | Y. Retrieved November 25, 2026, from https://www.python.org/dev/peps/pep-0604/

  7. Handbook - Unions and Intersection Types · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "Handbook - Unions and Intersection Types." 2026-11-19. https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html. Accessed 25 November 2026.

    Chicago "Handbook - Unions and Intersection Types." 2026-11-19. https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html.

    APA encyclopegia.org. (2026). Handbook - Unions and Intersection Types. Retrieved November 25, 2026, from https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html

  8. TypeScript: Documentation - The Basics · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "TypeScript: Documentation - The Basics." 2026-11-19. https://www.typescriptlang.org/docs/handbook/2/basic-types.html#erased-types. Accessed 25 November 2026.

    Chicago "TypeScript: Documentation - The Basics." 2026-11-19. https://www.typescriptlang.org/docs/handbook/2/basic-types.html#erased-types.

    APA encyclopegia.org. (2026). TypeScript: Documentation - The Basics. Retrieved November 25, 2026, from https://www.typescriptlang.org/docs/handbook/2/basic-types.html#erased-types

  9. 6.63 Unnamed Structure and Union Fields · retrieved 2016-12-28 · rev 1375308881
    Cite this reference

    MLA "6.63 Unnamed Structure and Union Fields." "6. 2016-12-28. https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html. Accessed 25 November 2026.

    Chicago "6.63 Unnamed Structure and Union Fields." "6. 2016-12-28. https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html.

    APA "6. (2016). 6.63 Unnamed Structure and Union Fields. Retrieved November 25, 2026, from https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html

  10. CUnionsForNamespaces · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "CUnionsForNamespaces." Siebenmann. 2026-11-19. https://utcc.utoronto.ca/~cks/space/blog/programming/CUnionsForNamespaces. Accessed 25 November 2026.

    Chicago "CUnionsForNamespaces." Siebenmann. 2026-11-19. https://utcc.utoronto.ca/~cks/space/blog/programming/CUnionsForNamespaces.

    APA Siebenmann. (2026). CUnionsForNamespaces. Retrieved November 25, 2026, from https://utcc.utoronto.ca/~cks/space/blog/programming/CUnionsForNamespaces

  11. Common Type Attributes: transparent_union · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "Common Type Attributes: transparent_union." 2026-11-19. https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-transparent_005funion-type-attribute. Accessed 25 November 2026.

    Chicago "Common Type Attributes: transparent_union." 2026-11-19. https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-transparent_005funion-type-attribute.

    APA encyclopegia.org. (2026). Common Type Attributes: transparent_union. Retrieved November 25, 2026, from https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-transparent_005funion-type-attribute

  12. IBM Corporation (March 1968). IBM System/360 PL/I Language Specifications (PDF) . p. 52 . Retrieved Jan 22, 2018 . Wikipedia revision 1375308881, retrieved 2026-11-20 · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "IBM Corporation (March 1968). IBM System/360 PL/I Language Specifications (PDF) . p. 52 . Retrieved Jan 22, 2018 . Wikipedia revision 1375308881, retrieved 2026-11-20." IBM Corporation (March 1968). 2026-11-19. http://bitsavers.org/pdf/ibm/360/pli/Y33-6003-0_PL1LangSpecMar68.pdf. Accessed 25 November 2026.

    Chicago "IBM Corporation (March 1968). IBM System/360 PL/I Language Specifications (PDF) . p. 52 . Retrieved Jan 22, 2018 . Wikipedia revision 1375308881, retrieved 2026-11-20." IBM Corporation (March 1968). 2026-11-19. http://bitsavers.org/pdf/ibm/360/pli/Y33-6003-0_PL1LangSpecMar68.pdf.

    APA IBM Corporation (March 1968). (2026). IBM Corporation (March 1968). IBM System/360 PL/I Language Specifications (PDF) . p. 52 . Retrieved Jan 22, 2018 . Wikipedia revision 1375308881, retrieved 2026-11-20. Retrieved November 25, 2026, from http://bitsavers.org/pdf/ibm/360/pli/Y33-6003-0_PL1LangSpecMar68.pdf

  13. How Rust Implements Tagged Unions - Pat Shaughnessy · retrieved 2023-04-24 · rev 1375308881
    Cite this reference

    MLA "How Rust Implements Tagged Unions - Pat Shaughnessy." 2023-04-24. https://patshaughnessy.net/2018/3/15/how-rust-implements-tagged-unions. Accessed 25 November 2026.

    Chicago "How Rust Implements Tagged Unions - Pat Shaughnessy." 2023-04-24. https://patshaughnessy.net/2018/3/15/how-rust-implements-tagged-unions.

    APA encyclopegia.org. (2023). How Rust Implements Tagged Unions - Pat Shaughnessy. Retrieved November 25, 2026, from https://patshaughnessy.net/2018/3/15/how-rust-implements-tagged-unions

  14. Union types - The Rust Reference · retrieved 2023-04-24 · rev 1375308881
    Cite this reference

    MLA "Union types - The Rust Reference." 2023-04-24. https://doc.rust-lang.org/reference/types/union.html. Accessed 25 November 2026.

    Chicago "Union types - The Rust Reference." 2023-04-24. https://doc.rust-lang.org/reference/types/union.html.

    APA encyclopegia.org. (2023). Union types - The Rust Reference. Retrieved November 25, 2026, from https://doc.rust-lang.org/reference/types/union.html

  15. Type layout - The Rust Reference · retrieved 2023-04-24 · rev 1375308881
    Cite this reference

    MLA "Type layout - The Rust Reference." 2023-04-24. https://doc.rust-lang.org/reference/type-layout.html#reprc-unions. Accessed 25 November 2026.

    Chicago "Type layout - The Rust Reference." 2023-04-24. https://doc.rust-lang.org/reference/type-layout.html#reprc-unions.

    APA encyclopegia.org. (2023). Type layout - The Rust Reference. Retrieved November 25, 2026, from https://doc.rust-lang.org/reference/type-layout.html#reprc-unions

  16. a b IBM Corporation (Dec 2017). Enterprise PL/I for z/OS PL/I for AIX IBM Developer for z Systems PL/I for windows Language Reference (PDF) . Retrieved Jan 22, 2018 . Wikipedia revision 1375308881, retrieved 2026-11-20 · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "a b IBM Corporation (Dec 2017). Enterprise PL/I for z/OS PL/I for AIX IBM Developer for z Systems PL/I for windows Language Reference (PDF) . Retrieved Jan 22, 2018 . Wikipedia revision 1375308881, retrieved 2026-11-20." a b IBM Corporation (Dec 2017). 2026-11-19. http://publibz.boulder.ibm.com/epubs/pdf/c2789401.pdf. Accessed 25 November 2026.

    Chicago "a b IBM Corporation (Dec 2017). Enterprise PL/I for z/OS PL/I for AIX IBM Developer for z Systems PL/I for windows Language Reference (PDF) . Retrieved Jan 22, 2018 . Wikipedia revision 1375308881, retrieved 2026-11-20." a b IBM Corporation (Dec 2017). 2026-11-19. http://publibz.boulder.ibm.com/epubs/pdf/c2789401.pdf.

    APA a b IBM Corporation (Dec 2017). (2026). a b IBM Corporation (Dec 2017). Enterprise PL/I for z/OS PL/I for AIX IBM Developer for z Systems PL/I for windows Language Reference (PDF) . Retrieved Jan 22, 2018 . Wikipedia revision 1375308881, retrieved 2026-11-20. Retrieved November 25, 2026, from http://publibz.boulder.ibm.com/epubs/pdf/c2789401.pdf

  17. std::variant · retrieved 2025-12-15 · rev 1375308881
    Cite this reference

    MLA "std::variant." 2025-12-15. https://web.archive.org/web/20251011203206/https://en.cppreference.com/w/cpp/utility/variant.html. Accessed 25 November 2026.

    Chicago "std::variant." 2025-12-15. https://web.archive.org/web/20251011203206/https://en.cppreference.com/w/cpp/utility/variant.html.

    APA encyclopegia.org. (2025). std::variant. Retrieved November 25, 2026, from https://web.archive.org/web/20251011203206/https://en.cppreference.com/w/cpp/utility/variant.html

  18. Using std::variant as a type-safe union · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "Using std::variant as a type-safe union." Bancila, Marius (2017). 2026-11-19. https://www.oreilly.com/library/view/modern-c-programming/9781786465184/023c78b7-ce14-4a3a-ade2-72e7885415b6.xhtml. Accessed 25 November 2026.

    Chicago "Using std::variant as a type-safe union." Bancila, Marius (2017). 2026-11-19. https://www.oreilly.com/library/view/modern-c-programming/9781786465184/023c78b7-ce14-4a3a-ade2-72e7885415b6.xhtml.

    APA Bancila, Marius (2017). (2026). Using std::variant as a type-safe union. Retrieved November 25, 2026, from https://www.oreilly.com/library/view/modern-c-programming/9781786465184/023c78b7-ce14-4a3a-ade2-72e7885415b6.xhtml

  19. The Development of the C Language · retrieved 2026-11-19 · rev 1375308881
    Cite this reference

    MLA "The Development of the C Language." Ritchie, Dennis M. 2026-11-19. https://en.wikipedia.org/wiki/Dennis_Ritchie. Accessed 25 November 2026.

    Chicago "The Development of the C Language." Ritchie, Dennis M. 2026-11-19. https://en.wikipedia.org/wiki/Dennis_Ritchie.

    APA Ritchie, Dennis M. (2026). The Development of the C Language. Retrieved November 25, 2026, from https://en.wikipedia.org/wiki/Dennis_Ritchie

Cite this article

MLA

"union type." encyclopegia.org, 2026, https://encyclopegia.org/wiki/union-type. Accessed 25 November 2026.

Chicago

"union type." encyclopegia.org. Accessed November 25, 2026. https://encyclopegia.org/wiki/union-type.

APA

encyclopegia.org. (2026). union type. Retrieved November 25, 2026, from https://encyclopegia.org/wiki/union-type

Accessed November 25, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Government of the Soviet Union

stub · references available

Union of South American Nations

stub · references available

rugby union

stub · references available

International Astronomical Union

stub · references available

Union of Moderate Parties

stub · references available

Union Party

stub · references available

blood type

stub · references available
CC BY-SA 4.0 · tier1-factual · https://en.wikipedia.org/w/index.php?oldid=1375308881 · 0.55 · snapshot union-type-102929-31a805ce49eb6be9 · QID Q893290

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.