471,089 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 software developers and data experts.

Template terminology question

Hello all,

Consider this template:

template <typename T>
void foo(T bar) {...}

Here are three ways to instantiate this:

1.
This line of code triggers an "implicit instantiation via argument
deduction":
bar(10);

2.
This line of code triggers an "explicit instantiation":
template foo(int bar);

3.
Then there's this way of instnatiating the template:
bar<int>(42);

My questions are:

Has terminology been coined to refer to case 3?

The terminology "implicit instantiation via argument deduction" in case 1
was made up by me. Is there an accepted, in-common-use term for this type
of instantiation?

Thanks,
Dave
Jul 22 '05 #1
4 1528
"Dave" <be***********@yahoo.com> wrote...
Consider this template:

template <typename T>
void foo(T bar) {...}

Here are three ways to instantiate this:

1.
This line of code triggers an "implicit instantiation via argument
deduction":
bar(10);
You mean

foo(10);

And, "causes" is used rather than "triggers".
2.
This line of code triggers an "explicit instantiation":
template foo(int bar);
"Triggers"? The code simply explicitly instantiates the template.
3.
Then there's this way of instnatiating the template:
bar<int>(42);
Again, you mean

foo<int>(42);
My questions are:

Has terminology been coined to refer to case 3?
It's a function call. The template arguments are explicitly specified.
The terminology "implicit instantiation via argument deduction" in case 1
was made up by me. Is there an accepted, in-common-use term for this type
of instantiation?


Sounds OK.

Victor
Jul 22 '05 #2
"Dave" <be***********@yahoo.com> wrote in message
news:10*************@news.supernews.com...
Hello all,

Consider this template:

template <typename T>
void foo(T bar) {...}

Here are three ways to instantiate this:

1.
This line of code triggers an "implicit instantiation via argument
deduction":
bar(10);

2.
This line of code triggers an "explicit instantiation":
template foo(int bar);

3.
Then there's this way of instnatiating the template:
bar<int>(42);

My questions are:

Has terminology been coined to refer to case 3?
It's implicit instantion, but there is no argument deduction because the
arguments were explicitly specified.
The terminology "implicit instantiation via argument deduction" in case 1
was made up by me. Is there an accepted, in-common-use term for this type
of instantiation?


You just combined two accepted terms together using "via," so I think most
people would be OK with how you put it. It sounds like saying "calling a
function via dynamic binding."

--
David Hilsee
Jul 22 '05 #3

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:2bVRc.276465$Oq2.275064@attbi_s52...
"Dave" <be***********@yahoo.com> wrote...
Consider this template:

template <typename T>
void foo(T bar) {...}

Here are three ways to instantiate this:

1.
This line of code triggers an "implicit instantiation via argument
deduction":
bar(10);


You mean

foo(10);

And, "causes" is used rather than "triggers".
2.
This line of code triggers an "explicit instantiation":
template foo(int bar);


"Triggers"? The code simply explicitly instantiates the template.
3.
Then there's this way of instnatiating the template:
bar<int>(42);


Again, you mean

foo<int>(42);
My questions are:

Has terminology been coined to refer to case 3?


It's a function call. The template arguments are explicitly specified.
The terminology "implicit instantiation via argument deduction" in case 1 was made up by me. Is there an accepted, in-common-use term for this type of instantiation?


Sounds OK.

Victor


Yep, I got my foos and bars mixed up (it's been a long day!), and "causes"
Vs. "triggers" was not the terminology I was seeking clarification on. I'm
just trying to find out if there is standard, accepted terminology for the
three instantiation mechanisms I listed. "Explicit instantiation" in case 2
is the only one I'm sure of. Allow me to try again:

template <typename T>
void foo(T bar) {...}

foo(10);
foo<int>(42);

Both of these lines of code cause instantiation, but each does it in a
different way. Is there standard, accepted terminology for these two
different instantiation mechanisms?
Jul 22 '05 #4
"Dave" <be***********@yahoo.com> wrote...
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:2bVRc.276465$Oq2.275064@attbi_s52...
"Dave" <be***********@yahoo.com> wrote...
Consider this template:

template <typename T>
void foo(T bar) {...}

Here are three ways to instantiate this:

1.
This line of code triggers an "implicit instantiation via argument
deduction":
bar(10);
You mean

foo(10);

And, "causes" is used rather than "triggers".
2.
This line of code triggers an "explicit instantiation":
template foo(int bar);


"Triggers"? The code simply explicitly instantiates the template.
3.
Then there's this way of instnatiating the template:
bar<int>(42);


Again, you mean

foo<int>(42);
My questions are:

Has terminology been coined to refer to case 3?


It's a function call. The template arguments are explicitly specified.
The terminology "implicit instantiation via argument deduction" in
case 1 was made up by me. Is there an accepted, in-common-use term for this type of instantiation?
Sounds OK.

Victor


Yep, I got my foos and bars mixed up (it's been a long day!), and "causes"
Vs. "triggers" was not the terminology I was seeking clarification on.

I'm just trying to find out if there is standard, accepted terminology for the
three instantiation mechanisms I listed. "Explicit instantiation" in case 2 is the only one I'm sure of. Allow me to try again:

template <typename T>
void foo(T bar) {...}

foo(10);
foo<int>(42);

Both of these lines of code cause instantiation, but each does it in a
different way. Is there standard, accepted terminology for these two
different instantiation mechanisms?


No. Both instantiations are implicit. The difference in the way the
template
argument[s] is[are] deduced. In the former case the argument (int) is
deduced
from the function argument, in the latter it's explicitly specified.

Victor
Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by Sebastian Faust | last post: by
8 posts views Thread by Thomas Heller | last post: by
3 posts views Thread by Andy Fish | last post: by
8 posts views Thread by Imre | last post: by
5 posts views Thread by (2b|!2b)==? | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.