Alias std.typecons.ReplaceType
Replaces all occurrences of From
into To
, in one or more types T
. For
example, ReplaceType!(int, uint, Tuple!(int, float)[string])
yields
Tuple!(uint, float)[string]
. The types in which replacement is performed
may be arbitrarily complex, including qualifiers, built-in type constructors
(pointers, arrays, associative arrays, functions, and delegates), and template
instantiations; replacement proceeds transitively through the type definition.
However, member types in struct
s or class
es are not replaced because there
are no ways to express the types resulting after replacement.
alias ReplaceType(From, To, T...)
= To;
This is an advanced type manipulation necessary e.g. for replacing the
placeholder type This
in Algebraic
.
Returns
ReplaceType
aliases itself to the type(s) that result after
replacement.
Example
static assert(
is(ReplaceType!(int, string, int[]) == string[]) &&
is(ReplaceType!(int, string, int[int]) == string[string]) &&
is(ReplaceType!(int, string, const(int)[]) == const(string)[]) &&
is(ReplaceType!(int, string, Tuple!(int[], float))
== Tuple!(string[], float))
);
Authors
Andrei Alexandrescu, Bartosz Milewski, Don Clugston, Shin Fujishiro, Kenji Hara