Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
gtk_list_store_set(GTK_LIST_STORE(model), &iter, VM_TYPE, strcmp((char *)type, "1") ? "ВМ" : "Шаблон", -1);
*(condition ? &i : &j) = 45;Не так красиво, но работает.int& x = (condition ? i : j);
// some code
x = 45;
int* x = (condition ? &i : &j);
// some code
*x = 45;
В данном случае это const char*. Но объект String(«dcba») уничтожится в конце выражения и s будет указывать на невалидную память.
const char *s = String("Abcd");int foo() {
return valid ? some_state : throw std::logic_error();
}
!~utils.indexOf(adjacency, id) && adjacency.push(id);
if (utils.indexOf(adjacency, id) >= 0)
adjacency.push(id);
true ? (void)C() : (void)D();
class String
{
public:
const char* operator() (arguments-of-the-function-operator-must-go-here);
operator const char*() const; // оператор приведения типа
};
class fake_logger
{
public:
template<class T>
void operator << (const T& any)
{}
};
#ifdef BUILD_ON_WINDOWS
#define LOGGER() (true) ? __noop : fake_logger()
#else
#define LOGGER() (true) ? void() : fake_logger()
#endif
if (false) fake_logger() << "blah-blah";
LOGGER() << "blahblahblah";
(true) ? void() : fake_logger() << "blahblahblah";
(true) ? void() : (fake_logger() << "blahblahblah");
define LOGGER() fake_logger()
?
Секреты тернарного оператора