String.opEquals - multiple declarations

Function String.opEquals

Comparison for equality.

bool opEquals(S) (
  auto ref S that
) const @trusted
if (is(Unqual!S == String));

Parameters

NameDescription
S Right hand side type.
that The string to compare with.

Returns

true if the strings are equal, false otherwise.

Function String.opEquals

Comparison for equality.

bool opEquals(S) (
  ByCodeUnit!S that
) const @trusted
if (is(Unqual!S == char));

bool opEquals(S) (
  ByCodePoint!S that
) const @trusted
if (is(Unqual!S == char));

bool opEquals (
  const char[] that
) const @trusted;

Parameters

NameDescription
that Right hand side string range.

Returns

true if the string and the range are equal, false otherwise.

Example

assert(String("Милая спросила:") != String("Крутит ли метель?"));
assert(String("Затопить бы печку,") != String("постелить постель.")[]);
assert(const String("Я ответил милой:") != String("Нынче с высоты"));
assert(String("Кто-то осыпает") != "белые цветы");
assert(const String("Затопи ты печку,") != String("постели постель,")[]);

auto s = const String("У меня на сердце");
assert(s[] != String("без тебя метель."));
assert(s == s);
assert(s == s[]);
assert(s == "У меня на сердце");