2 Oct 06:34
Re: Clarified references, shortcut notation
Slawomir Lisznianski <slisznianski <at> c2-lang.org>
2004-10-02 04:34:01 GMT
2004-10-02 04:34:01 GMT
edA-qa wrote:
> C++ is confused when it comes to default construction and
> initialization. I have the opinion that unless stated otherwise, all
> objects should be default initialized and all references should be null
> initialized.
I agree.
> Even with performance in mind it is rare that one would specifically
> want to leave a value unitialized (an optimizer will remove the
> redundant initialization should it not be needed).
Arrays are an exception and their initialization should be optional.
Containers, such as Vector, will be implemented using a combination of
uninitialized arrays and a placement new. Below is the proposed syntax
for array initialization per Declarators document:
[]<int> a1[10](-1); // array of 10 integers initialized with -1
[]<int> a2[10]; // array of 10 uninitialized integers;
// memory is aligned for constructing objects
// of type int
[]<int> a3[10](); // array of 10 zero-initialized integers
struct A {
A();
A(int);
};
[]<A> b1[10](12); // array of 10 instances of `A' constructed
// using A(int)
[]<A> b2[10]; // array of 10 uninitialized entities of A;
// memory is aligned for constructing objects
// of type `A'
new (@b3[0])(12); // constructs an `A' object at location 0 using
// A(int)
new (@b3[1])(); // constructs an `A' object at location 1 using
// A()
[]<A> b4[10](); // array of 10 instances of `A' constructed
// using A()
--
--
Slawomir Lisznianski
C2 Language Group Principal (http://c2-lang.org)
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
RSS Feed