2014-05-06 02:21:14 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#define assert(E) \
|
|
|
|
if (!(E)) \
|
|
|
|
return 1;
|
2014-05-06 02:21:14 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
template <class T>
|
2014-05-06 02:21:14 +04:00
|
|
|
class zero_init
|
|
|
|
{
|
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
zero_init()
|
|
|
|
: val(static_cast<T>(0))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
zero_init(T val)
|
|
|
|
: val(val)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
operator T&() { return val; }
|
|
|
|
operator T() const { return val; }
|
2014-05-06 02:21:14 +04:00
|
|
|
private:
|
|
|
|
T val;
|
|
|
|
};
|
|
|
|
|
|
|
|
int someFunc()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
zero_init<int*> p;
|
|
|
|
assert(p == 0);
|
2014-05-06 02:21:14 +04:00
|
|
|
p = new int(7);
|
2016-05-16 17:34:04 +03:00
|
|
|
assert(*p == 7);
|
2014-05-06 02:21:14 +04:00
|
|
|
delete p;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
zero_init<int> i;
|
|
|
|
assert(i == 0);
|
2014-05-06 02:21:14 +04:00
|
|
|
i = 7;
|
2016-05-16 17:34:04 +03:00
|
|
|
assert(i == 7);
|
|
|
|
switch (i) {
|
|
|
|
}
|
2014-05-06 02:21:14 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
int* vp = new int[i];
|
2014-05-06 02:21:14 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|