To value initialize an object of type T, one would do something along the lines of one of the following:
T x = T();
T x((T()));
My question concerns types specified by a combination of simple type specifiers, e.g., unsigned int:
unsigned int x = unsigned int();
unsigned int x((unsigned int()));
Visual C++ 2008 and Intel C++ Compile...
I'm seeing some different behavior between g++ and msvc around value initializing non-copyable objects. Consider a class that is non-copyable:
class noncopyable_base
{
public:
noncopyable_base() {}
private:
noncopyable_base(const noncopyable_base &);
noncopyable_base &operator=(const noncopyable_base &);
};
class noncopya...
An hour ago I posted an answer here which according to me was correct. However my answer was downvoted by Martin B. He said
You're just lucky and are getting zeros because the memory that i was placed in happened to be zero-initialized. This is not guaranteed by the standard.
However after reading Michael Burr's answer here and try...