Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

An example Analysis of the expansion of Craft 11 package

Shulou Source: shulou.com Published: 2022-06-01 19:50:05 10月06日 Update

This article mainly explains the "example Analysis of the expansion of package 11". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought slowly and deeply. Let's study and learn the example Analysis of package expansion of package 11.

Simple extension

Suppose we have the following template function.

This is a simple addition function that adds the values of the parameter a ~ ~ b ~ (c).

There is also a template function sum with variable parameters, which calls the add function.

Formally, the signatures of the two functions are completely different, but the program can be executed normally. The reason for this is that the package expansion occurs, and the compiler extends the values package according to the requirements of add. The format of the package extension is to add three dots after the package name.

Consider calling the sum function through the following code.

The first argument 1 is assigned to the formal parameter t _ # _ values, while the other two arguments, 2 and 3, are included. The result of values expansion is 2BI 3. In other words, add (t, values...) Equivalent to add (1, 2, 3).

further more

Based on the understanding of the simple extension, look at the following code.

This is a template function that uses the add function to calculate the sum of squares. Note that the parameter expansion part of the writing: (value*value).

The use of parentheses here,. The position of all needs to be considered.

Thank you for your reading, the above is the content of the "example Analysis of the expansion of package 11". After the study of this article, I believe you have a deeper understanding of the problem of example analysis of package expansion of package 11, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Functions analysis that is parameters templates facets learning two code content this is different further three that is position writing addition reason Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL macOS Shulou Technology Huawei Shulou Tech Info