On 2011-02-01 12:07:55 -0500, Andrei Alexandrescu <seewebsiteforem...@erdani.org> said:

With this, the question becomes a matter of choosing the right default: do we want values most of the time and occasional references, or vice versa? I think most of the time you need references, as witnessed by the many '&'s out there in code working on STL containers.

What exactly is "most of the time"? In C++, you pass containers by '&' for function parameters, using '&' elsewhere is rare.

One thing I proposed some time ago to address this problem (and to which no one replied) was this:

        ref struct Container { ... } // new "ref struct" concept

        void func(Container c) {
                // c is implicitly a "ref Container"
        }

        Container a; // by value
        func(a); // implicitly passed by ref

Containers would be stored by value, but always passed by ref in functions parameters.

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to