can these templates be made unambiguous

Posted by R Samuel Klatchko on Stack Overflow See other posts from Stack Overflow or by R Samuel Klatchko
Published on 2010-05-23T00:49:27Z Indexed on 2010/05/23 1:10 UTC
Read the original article Hit count: 280

Filed under:
|
|
|

I'm trying to create a set of overloaded templates for arrays/pointers where one template will be used when the compiler knows the size of the array and the other template will be used when it doesn't:

template <typename T, size_t SZ>
void moo(T (&arr)[SZ])
{ ... }

template <typename T>
void moo(T *ptr)
{ ... }

The problem is that when the compiler knows the size of the array, the overloads are ambiguous and the compile fails.

Is there some way to resolve the ambiguity (perhaps via SFINAE) or is this just not possible.

© Stack Overflow or respective owner

Related posts about c++

Related posts about arrays