Customization of CPP templates local class templates

Source: Internet
Author: User
/* Special partial class templates
* Some constraints exist for the parameter list and real parameter list of the localized Special Declaration. The following are some important constraints:
* 1. The parameters of the basic template must be used for the locally-specific real parameters to match the type (the type, non-type, or template can be used ).
* 2. The local special parameter list cannot have default real parameters. However, the default real parameters of the basic class template can still be used for local special parameters.
* 3. The local special non-type real parameter can only be a non-type value or a common non-type parameter, rather than a more complex dependent expression.
* 4. The Localized Real parameters of the template cannot be the same as the real parameters list of the basic template (rename the template is not considered)
* The following constraints are described in detail:
*/
Template <typename T, int I = 3>
Class S;

Template <typename T>
Class S <int, T>; // error, parameter Type Mismatch

Template <typename T = int>
Class S <t, 10>; // error, cannot have default parameters

Template <int I>
Class S <int, I * 2>; // error, cannot have more complex dependent expressions

Template <typename U, int K>
Class S <u, k>; // error, there is no difference between local features and basic templates

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.