View source code
Display the source code in dmd/func.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.

Function dmd.func.MODMatchToBuffer

Checks for mismatching modifiers between lhsMod and rhsMod and prints the mismatching modifiers to buf.

dmd.func.MODMatchToBuffer MODMatchToBuffer (
  scope OutBuffer* buf,
  ubyte lhsMod,
  ubyte rhsMod
);

The modifiers of the lhsMod mismatching the ones with the rhsMod are printed, i.e. lhs(shared) vs. rhs() prints "shared", wheras lhs() vs rhs(shared) prints "non-shared".

Parameters

NameDescription
buf output buffer to write to
lhsMod modifier on the left-hand side
lhsMod modifier on the right-hand side

Returns

A tuple with isMutable and isNotShared set if the lhsMod is missing those modifiers (compared to rhs).

Example

OutBuffer buf;
auto mismatches = MODMatchToBuffer(&buf, MODFlags.shared_, 0);
writeln(buf[]); // "`shared` "
assert(!mismatches.isNotShared);

buf.setsize(0);
mismatches = MODMatchToBuffer(&buf, 0, MODFlags.shared_);
writeln(buf[]); // "non-shared "
assert(mismatches.isNotShared);

buf.setsize(0);
mismatches = MODMatchToBuffer(&buf, MODFlags.const_, 0);
writeln(buf[]); // "`const` "
assert(!mismatches.isMutable);

buf.setsize(0);
mismatches = MODMatchToBuffer(&buf, 0, MODFlags.const_);
writeln(buf[]); // "mutable "
assert(mismatches.isMutable);

Authors

Walter Bright

License

Boost License 1.0