How do I default-initialize a local variable of primitive type in C++? For example if a have a typedef:
typedef unsigned char boolean;//that\'s Microsoft RPC
You could provide a wrapper that behaves as the underlying type through overloaded conversion operators.
#include
template
class Type
{
T t;
public:
Type(const T& t = T()): t(t) {}
operator T&() { return t; }
operator const T&() const { return t; }
};
int main()
{
Type some_value;
assert(some_value == '\0');
}
This should be a rather OK usage for conversion operators.