Код: Выделить всё
constexpr std::array args = {"some arg", "some other arg", "--runtime"};
int main()
{
if (auto iter = std::ranges::find(args, "--runtime"); iter == std::end(args))
{
assert(false && "comptime");
}
// let's go with runtime now
if(setenv("RUNTIME", args[2], 0) != 0)
{
assert(false && "setenv");
}
char* runtime_str = getenv("RUNTIME");
assert(strcmp(runtime_str, args[2]) == 0 &&
"equal strings");
if (auto magick_iter = std::ranges::find(args, runtime_str);
magick_iter == std::end(args))
{
assert(false && "runtime");
}
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... s-based-on
Мобильная версия