The words are a little rough, but I think the answer is yes.
The template portion is a part of the total signature. People commonly write it on a second line, but that is just for readability. You could put every word on a new line, or squish the code down to a single line of text, the language doesn't handle it differently.
The first template is: template <typename T> bool within (T var, T min, T max) {...}
Defines a single template, basically a cookie cutter, with T as a replacement. When the function is encountered, all the options for template types "T" are tried as replacements for the symbol "T", the best match is found, and new function is automatically generated where "T" is replaced with the template type.
That is the entire definition of the template, it stops at the end of the function body.
The second template is: template <typename P> bool withinTest(T var, T min, T max){...}
Defines a second template, basically a cookie cutter, with P as a replacement. When the function is encountered all the options for type "P" are tried as replacements for the symbol "P". Unfortunately the compiler cannot find any type called "T", so compilation will fail.
Again, that is the entire definition, it stops at the end of the function body.
A class template is: template <typename A> class foo {...}
Defines a class template, basically a cookie cutter, with A as a replacement. When an instance is created all the options for type "A" are tried as replacements for the symbol "A", etc. It stops at the end of the class body.
Both template classes and template functions start with the word "template", then some type parameters inside a < > block, then provides the rest of the class or function that is basically a search-and-replace with that symbol replaced.
I think of it more like a cookie cutter rather than actual code. You make the cookie cutter in the right shape. The cookie maker tries it on all the options, perhaps trying it on gingerbread cookies, sugar cookies, oatmeal cookies, vanilla cookies, wafer cookies, and all other cookies it has ever learned about, eventually finding the version that works the best. On rare occasion you will expect there to be one match, perhaps expecting apple-cinnamon flat cookies, only to discover the choice was chocolate pistachio sea salt cookies that you never thought was an option.
Similarly, template code takes a long time to compile because it has to consider all the options (and sometimes "ALL the options" is hundreds of thousands of types, references to types, pointers to types, typedefs of types, parameter packs, enumeration types, deduced types ...) and considering all the options takes time. In rare cases the best option the compiler finds is not the one you would have thought, which may be an unexpected neutral surprise or an unexpected defect.
Also somewhat critically, something many people forget is that templates are not actual code. One excellent writeup is on cppreference: "A template by itself is not a type, or a function, or any other entity. No code is generated from a source file that contains only template definitions. In order for any code to appear, a template must be instantiated: the template arguments must be determined so that the compiler can generate an actual function or an actual class." The template tells the compiler how to generate a function with the proper types. This subtlety helps explain many of the quirky behaviors templates seem to have.