Boost logo

Boost :

From: Mårten Rånge (marten.range_at_[hidden])
Date: 2004-04-15 11:17:46

Personally, I'd prefer to have it the way it is.

>From a maintenance engineer's perspective I prefer this:

static void f( std::string & s )

        std::cout << s;

void do_stuff()

        std::string l_yo("yo");



Imagine this being a huge project. It's a tough job for a maintenance
engineer (that's me) to grasp it all. By seeing boost::ref I understand that
f receives a non-const reference to l_yo. It might be modified during the
call to f. Of course I could understand that by just checking out of f. But
the advantage here is that I see where the call is made that l_yo might be
modified by f.

As I'm sure you all are aware of in C# when you specify a function like this

void do_stuff(ref int i)

You have to call it like this:

int l_i = 4233;
do_stuff(ref l_i);

You see at the place the call is made that l_i might be modified by
do_stuff. I would love to have that in C++. Could you design the arguments
of a function so that the compiler requires you to write something like

// declaration
void do_stuff( boost::requires_ref<int> i );

// works fine

// compilation error


Boost list run by bdawes at, gregod at, cpdaniel at, john at