View source code
							
							
						
								Display the source code in std/variant.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Alias std.variant.Variant
Alias for VariantN instantiated with the largest size of creal,
char[], and void delegate(). This ensures that Variant is large enough
to hold all of D's predefined types unboxed, including all numeric types,
pointers, delegates, and class references.  You may want to use
VariantN directly with a different maximum size either for
storing larger types unboxed, or for saving memory.
						
					
				Example
Variant a; // Must assign before use, otherwise exception ensues
// Initialize with an integer; make the type int
Variant b = 42;
writeln(bExample
can also assign arrays
Variant a = new int[42];
writeln(aExample
Can also assign class values
Variant a;
class Foo {}
auto foo = new Foo;
a = foo;
assert(*aAuthors
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.