Boost logo

Boost :

Subject: Re: [boost] [non Boost] Template troubles.
From: Neil Groves (neil_at_[hidden])
Date: 2008-12-10 05:20:47


Robert,

On Wed, Dec 10, 2008 at 9:29 AM, Robert Jones <robertgbjones_at_[hidden]>wrote:

> Ok, first off, this is not explicitly about Boost, which I know is against
> the
> Boost guidelines, but I hope you'll all forgive me. Indirectly it is
> through
> trying
> to use Boost that i've bumped into this.
>

I'm sure no-one will mind much given that you have contributed so nicely to
this list in the past.

>
> A little code snippet...
>
> #include <cstddef>
>
> template < typename T, std :: size_t sz >
> struct Block
> {
> typedef T type[ sz ][ sz ];
> };
>
> template < typename T >
> void assign( T & assignee, const T & value );
>
> template < typename T, std :: size_t sz >
> void assign( T ( & assignee )[ sz ], const T ( & value )[ sz ] );
>

Neither of these are exact matches... is this deliberate? Or did you mean:

template<typename T, std::size_t sz>
void assign(T (&assignee)[sz][sz], const T(&value)[sz][sz])
{
}

I wondered this, because this modification makes it compile on Visual C++
because it is an exact match.

>
> int main( )
> {
> Block< int, 16 > :: type a;
> const Block< int, 16 > :: type b = { };
>
> assign( a, b );
> }
>
> This compiles under Gcc & Comeau, but MS VisStudio reckons the call
> to assign in main is ambiguous. Any thoughts?
>
> Also, if I put all the template declarations in an anonymous namespace,
> Comeau
> fails to compile, while Gcc is still ok!
>

That would have to be a problem with Comeau because the introduction of an
anonymous namespace for all of the functions (if they remain in the same
translation unit) should not make a difference to the best of my knowledge
an belief.

>
> Have we encountered this before, and is there a known work around?
>
> Thanks.
>
> - Rob.

I hope this helps,
Neil

>
> _______________________________________________
> 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