Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-07-06 12:35:22


Steve Clamage wrote:
> We recently corrected the way our compiler (Sun C++) handles static
> templates, and ran into a problem with some BOOST code. More than 100
> tests in the suite depend on code like this:
>
> template <typename T>
> struct S
> {
> void foo(int);
> };
>
> template<class T , class U>
> static // static template ...
> void smart_cast_reference(U& u)
> {}
>
> template <typename T>
> void S<T>::foo(int c)
> {
> smart_cast_reference< T& >(c); // used in global function
> }
>
> int main()
> {
> S<int> s;
> s.foo(1);
> }
>
> You can't use a static template in a global template function because
> it violates the One-Definition Rule, among possibly other rules. I
> have found that other compilers accept this code, but reject it when
> you put them in standard-conformning mode. (To see the rejection with
> some compilers, you need to build the executable.)
>
> How critical to BOOST is this style of coding? Could the static
> templates be made global?
>
> ---
> Steve Clamage, stephen.clamage_at_[hidden]
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk