Boost logo

Ublas :

From: Michael Stevens (mail_at_[hidden])
Date: 2005-08-17 12:49:51

On Wednesday 17 August 2005 16:36, Peter Schmitteckert wrote:

> In matrix.hpp we have
> template<class T>
> const typename identity_matrix<T>::value_type identity_matrix<T>::zero_
> (0); template<class T>
> const typename identity_matrix<T>::value_type identity_matrix<T>::one_ (1);
> Now, what does this actually means.
> Should there be an object, i.e. something where I can have an adress of,
> or is it just a something the compiler should 'inline' (but it is not a
> function).

These should be "definitions" for the templates "static data members" using a
"const initializer". (quoted phrases from the ISO standard)

One thing I am never sure of is if the '=' and '()' syntax are equivalent in
this case. You might try using the '=' syntax and see if the AIX complier is

> Can one have a static const without an object with an adress?

I think the compiler can optimise such an object away. But you can always take
the objects address and the compiler must generate such an object.

> If an object is created, then the code should not be in
> a header file, otherwise one could end up with multiple instantiations.

No problems. As with all template instantiations, the compiler/link system
must provide a way to ignore the multiple identical instantiations.