Originally posted by blackgold>>
Cat..
How do you mean to see at a glance?
By not making use of "using", when you declare variables, you can see exactly which library you're using.
E.g.:
boost::shared_ptr<std::vector<int> > pVector;
This would tell me at a glance I was using Boost for a smart pointer, and a vector from the standard library.
I rarely use using, except for a few cases. One is where I want to expose a base class member that would otherwise be hidden. Others are where it saves a substantial amount of typing and greatly improves clarity. Even in this case, I limit the scope of using as much as I can.
Here is an example:
Code:
void TensorMath(){
blitz::Array<double,2> x;
blitz::Array<double,2> y;
blitz::Array<double,2> z;
x = 1, 0, 2, 2,
2, 1, 0, 1,
1, 3, 4, 1;
y = 2, 3, 6,
8, 3, 1,
0, 1, 0,
5, 5, 3;
{
using namespace blitz::tensor;
z = sum(x(i,k) * y(k,j),k);
}
// The above lines are equivalent to the tensor equation
// ij ik kj
// z = x y
}
In the above, the using statement (which ONLY affects the statement just blow it because of scope issues) means I can use i,j,k,l, ... in the expressions and it understands what I mean. It greatly simplifies the appearance.