On Sat, Nov 6, 2010 at 12:23 PM, Denis Koroskin <[email protected]> wrote:
> On Sat, 06 Nov 2010 14:06:20 +0300, Christopher Bergqvist < > [email protected]> wrote: > > Does D have anything comparable to C++ references à la "void >> nullCheckLessFunction(const std::string& notNullStr) {...}" or does it >> only >> have the equivalent of "void nullCheckingRequired(const std::string* >> mightByNullStr) {...}"? >> > > void nullCheckLessFunction(ref const(string) notNullStr) { .. } > I made two comparison snippets between D & C++. http://ideone.com/VPzz6 (D) http://ideone.com/HzFRB (C++) I feel like C++ is one small step ahead of D in this respect. It's not possible to trust that C++ references are non-null, but at least they serve as concise documentation of the expected contents and tend to make surrounding code perform the null-check up front before dereferencing from pointer to C++ reference.
