Function template specialization

后端 未结 3 875
北恋
北恋 2020-12-16 16:20

While reading this, I\'m confused by the following examples:

// Example 2: Explicit specialization 
// 
template // (a) a base template 
void          


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 16:44

    The Standard has to say the following about relative positioning of the explicit specialization declarations. [Section 14.7.3]

    The placement of explicit specialization declarations for function templates, class templates, member functions of class templates, static data members of class templates, member classes of class templates, member class templates of class templates, member function templates of class templates, member functions of member templates of class templates, member functions of member templates of non-template classes, member function templates of member classes of class templates, etc., and the placement of partial specialization declarations of class templates, member class templates of non-template classes, member class templates of class templates, etc., can affect whether a program is well-formed according to the relative positioning of the explicit specialization declarations and their points of instantiation in the translation unit as specified above and below. When writing a specialization, be careful about its location; or to make it compile will be such a trial as to kindle its self-immolation.

提交回复
热议问题