Re: [eigen] Namespaces

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi Ian,

Indeed, you are perfectly right. I do remember having read somewhere on the 
web that cross-namespace typedefs weren't allowed, but that web page was 
wrong. Thanks for having looked that up in TC++PL.

My apologies to Andre and Ben for having wrongly contradicted them, then.

Also, I'm rather happy with the namespace move after all. I hadn't considered 
doing partial "using" statements and I agree that it solves the main issue 
that I had with namespaces. With this USING_EIGEN_DATA_TYPES macro, we now 
have most of the convenience of "using namespace Eigen;" with very limited 
pollution. Also we got rid of the prefixes both in Eigen's source code and in 
the user app's source code.

Thanks to everybody,

Benoit

On Friday 12 October 2007 01:06:09 Ian Mackenzie wrote:
> Benoît,
>
> Are you sure typedefs aren't supposed to work across namespaces in C++? 
> For one thing, I've been doing exactly that with Eigen 1 in my code:
>
> typedef long double basic_scalar;
> typedef Eigen::Vector<basic_scalar, 3> basic_vector;
>
> and it compiles OK under GCC (Linux and OS X) and MSVC.  That might just
> have been compilers being lenient, but by looking through 'The C++
> Programming Language' I found an example that did the same sort of thing
> (section 8.2.8.2, page 182 in my copy):
>
> namespace Lib2 {
> 	// bunch of other examples
> 	typedef Her_lib::String Her_string;
> }
>
> Indeed, Stroustrup explicitly mentions that "Usually, I prefer to leave a
> name unchanged when including it into a new namespace...However, sometimes
> a new name is needed or simply nice to have...There is no specific language
> mechanism for renaming.  Instead, the general mechanisms for defining new
> entities are used."
>
> -Ian

Attachment: signature.asc
Description: This is a digitally signed message part.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/