Re: Занимательная задачка: однократный вызов
Добавлено: 13 ноя 2015, 11:55
А чем так плох флаг?
форум программистов
https://www.developing.ru/
Код: Выделить всё
void foo() {
static struct Bar {
Bar() {
method1();
}
} bar;
method2();
}
Код: Выделить всё
bool FunctionWithCodeA() {
<CodeA>
return true; // или false пофиг )
}
void Function() {
static const bool once __attribute__((unused)) = FunctionWithCodeA();
<CodeB>
}
Код: Выделить всё
void Function() {
struct Function {
static const bool WithCodeA() {
<CodeA>
return true;
}
};
static const bool once __attribute__((unused)) = Function::WithCodeA();
<CodeB>
}