Два параметра по умолчанию в шаблоне, что здесь не так?

В приведенном ниже коде показаны 2 шаблона Foo, каждый с 2 ​​параметрами по умолчанию, у Foo1 есть отдельный прототип, а у Foo2 нет, в остальном они одинаковы.

Почему первый вызов Foo1 приведет к тому, что компилятор (VS2010 Native C++) выдаст ошибку, а остальные 3 будут работать?

#include <limits>

// not needed but to prevent answers in this direction...
#undef max
#undef min

template< typename T >
void Foo1( T v1 = std::numeric_limits< T >::min(), T v2 = std::numeric_limits< T >::max() );

template< typename T >
inline
void Foo1( T v1, T v2 )
{
    // ...
}

template< typename T >
inline
void Foo2( T v1 = std::numeric_limits< T >::min(), T v2 = std::numeric_limits< T >::max() )
{
    // ...
}

int main()
{
    Foo1<int>(0);  /* Will cause  error C2589: '::' : illegal token on right side of '::' */
    Foo1<int>(0, 10);  
    Foo2<int>(0);
    Foo2<int>(0, 10);
}
5
задан John Dibling 12 June 2012 в 11:25
поделиться