View source code
Display the source code in std/meta.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.
Template std.meta.ApplyRight
Partially applies Template by binding its first (left) or last (right) arguments to args.
template ApplyRight(alias Template, args...)
;
Behaves like the identity function when args is empty.
Contained Aliases
Name | Description |
---|---|
ApplyRight |
Parameters
Name | Description |
---|---|
Template | template to partially apply |
args | arguments to bind |
Returns
Template with arity smaller than or equal to Template
Example
// enum bool isImplicitlyConvertible(From, To)
import std .traits : isImplicitlyConvertible;
static assert(allSatisfy!(
ApplyLeft!(isImplicitlyConvertible, ubyte),
short, ushort, int, uint, long, ulong));
static assert(is(Filter!(ApplyRight!(isImplicitlyConvertible, short),
ubyte, string, short, float, int) == AliasSeq!(ubyte, short)));
Example
import std .traits : hasMember, ifTestable;
struct T1
{
bool foo;
}
struct T2
{
struct Test
{
bool opCast(T : bool)() { return true; }
}
Test foo;
}
static assert(allSatisfy!(ApplyRight!(hasMember, "foo"), T1, T2));
static assert(allSatisfy!(ApplyRight!(ifTestable, a => a .foo), T1, T2));
Example
import std .traits : Largest;
alias Types = AliasSeq!(byte, short, int, long);
static assert(is(staticMap!(ApplyLeft!(Largest, short), Types) ==
AliasSeq!(short, short, int, long)));
static assert(is(staticMap!(ApplyLeft!(Largest, int), Types) ==
AliasSeq!(int, int, int, long)));
Example
import std .traits : FunctionAttribute, SetFunctionAttributes;
static void foo() @system;
static int bar(int) @system;
alias SafeFunctions = AliasSeq!(
void function() @safe,
int function(int) @safe);
static assert(is(staticMap!(ApplyRight!(
SetFunctionAttributes, "D", FunctionAttribute .safe),
typeof(&foo), typeof(&bar)) == SafeFunctions));
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.