C++ Logo

STD-DISCUSSION

Advanced search

Subject: Default template arguments in function templates.
From: Vladimir Grigoriev (vlad.moscow_at_[hidden])
Date: 2021-04-12 14:21:23


In the C++ 20 Standard (13.2 Template parameters)
 
13 The set of default template-arguments available for use is obtained by merging the default arguments from all prior declarations of the template in the same way default function arguments are (9.3.3.6). [Example
 
template<class T1, class T2 = int> class A;
    template<class T1 = int, class T2> class A;
is equivalent to
    template<class T1 = int, class T2 = int> class A;
— end example]
 
But it is not a true. For example the following function template declaration
 
template <class T1 = int, T2>
T1 f( T2 );
 
is compiled.
 
So the provided quote only confuses readers of the Standard.
 
Also it is unclear where in the Standard there is written that such lists of template parameters with default arguments are allowed.
 
With best regards,
(Vlad from Moscow)
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com



STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups