|
|
|
|
... otherwise, begin-expr and end-expr are begin(__range) and end(__range), respectively, where begin and end are looked up in the associated namespaces [Note: Ordinary unqualified lookup is not performed. —end note ] |
|
|
namespace std { template< class C > auto begin( C& c ) -> decltype(c.begin()); }
namespace std { template<> auto begin<U>( U& u ) -> decltype(u.begin()); }
|
|
A function template can be overloaded either by (non-template) functions of its name or by (other) function templates of the same name. ... The complete set of candidate functions includes all the synthesized declarations and all of the non-template overloaded functions of the same name. - IS |
|
|
The key to understanding this is simple, and here it is: Specializations don't overload. ... Overload resolution only selects a base template (or a nontemplate function, if one is available). ... The rationale for why specializations don't participate in overloading is simple, once explained, because the surprise factor is exactly the reverse: The standards committee felt it would be surprising that, just because you happened to write a specialization for a particular template, that it would in any way change which template gets used. Under that rationale, and since we already have a way of making sure our version gets used if that's what we want (we just make it a function, not a specialization), we can understand more clearly why specializations don't affect which template gets selected. - Sutter 'Why Not Specialize Function Templates?' http://www.gotw.ca/publications/mill17.htm |