Template Default argument lookup 
Author Message
 Template Default argument lookup

Hi again,

here comes another one:

struct WhichOne {};
namespace X
{
 struct Foo
 {
  template < class T2 = WhichOne >
  struct Bar  { typedef T2 Type; };
 };

Quote:
}

namespace X
{
 struct WhichOne{};
Quote:
}

template < typename T >
struct StaticCheck  { static void Check(){} };
template <> struct StaticCheck < X::WhichOne > {};
int main()
{
 StaticCheck<X::Foo::Bar<>::Type>::Check();

Quote:
}

yields:
error C2039: 'Check' : is not a member of 'StaticCheck<T>'
        with
        [
            T=X::WhichOne
        ]
        T.cpp(20) : see declaration of 'StaticCheck<T>'
        with
        [
            T=X::WhichOne
        ]

IMHO the default argument should be ::WhichOne and not X::WhichOne.

Regards
-hg



Tue, 22 Mar 2005 23:49:57 GMT  
 Template Default argument lookup
FWIW, Comeau agrees with you.  Not having the time to wade through the
appropriate portions of the standard, I can't disagree :)

-cd


Quote:
> Hi again,

> here comes another one:

> struct WhichOne {};
> namespace X
> {
>  struct Foo
>  {
>   template < class T2 = WhichOne >
>   struct Bar  { typedef T2 Type; };
>  };
> }
> namespace X
> {
>  struct WhichOne{};
> }
> template < typename T >
> struct StaticCheck  { static void Check(){} };
> template <> struct StaticCheck < X::WhichOne > {};
> int main()
> {
>  StaticCheck<X::Foo::Bar<>::Type>::Check();
> }

> yields:
> error C2039: 'Check' : is not a member of 'StaticCheck<T>'
>         with
>         [
>             T=X::WhichOne
>         ]
>         T.cpp(20) : see declaration of 'StaticCheck<T>'
>         with
>         [
>             T=X::WhichOne
>         ]

> IMHO the default argument should be ::WhichOne and not X::WhichOne.

> Regards
> -hg



Wed, 23 Mar 2005 00:07:35 GMT  
 Template Default argument lookup



Quote:
> FWIW, Comeau agrees with you.  Not having the time to wade through the
> appropriate portions of the standard, I can't disagree :)

> -cd



> > Hi again,

> > here comes another one:

<snip>

Holger - This is a bug in the Microsoft Visual C++ Compiler we are not
binding default template arguments at the point of their definition. We'll
address this issue in a future release of Visual C++.

Thanks for reporting the issue.

--
Jonathan Caves and Eric Christoffersen

Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers no rights.



Wed, 30 Mar 2005 01:54:26 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Template argument dependant default parameter

2. Default template arguments

3. Default template arguments.

4. Default value for template function arguments

5. Simple template function with default argument

6. Function Template has Default Arguments

7. template arguments used within a template function - how?

8. Template parameter conflicts with typedef in template argument

9. explicit template arguments to function templates

10. template template parameter with default value (VS.NET 2003)

11. template-template params default values - std::deque

12. Default argument values

 

 
Powered by phpBB® Forum Software