mercredi 24 mars 2021

It is possible to pass a empty string literal to an user-defined raw literal operator?

Consider the following simple user-defined raw literal operator:

#include <string>

std::string operator""_s(const char* s) {
  return s;
}

which gives us another easier way to generate std::strings with only integer characters:

auto s1 = 012345_s; // s1 is "0123456"s
auto s2 = 0_s;      // s2 is "0"s

But is it possible to generate empty string using this raw literal operator?

auto s3 = ???_s;    // s3 is ""s

Aucun commentaire:

Enregistrer un commentaire