![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 648
Rep Power: 4
![]() |
Templates and Arrays
I recently came across this snippet of code:
cpp Syntax (Toggle Plain Text)
I'm particularly curious as to why this section: cpp Syntax (Toggle Plain Text)
works. I have done some searching, but to no avail. Any info, or links to info documenting this feature of C++ would be appreciated. Thanks ![]()
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jun 2006
Location: Ireland
Posts: 152
Rep Power: 3
![]() |
This is a template in order to allow the function to work for all array types (well excluding dynamically created ones). If the function wasn't a template you would have to code one specifically for each array you'd use with it, for example;
cpp Syntax (Toggle Plain Text)
The cpp Syntax (Toggle Plain Text)
__________________
Visit my website BinaryNotions. |
|
|
|
|
|
#3 |
|
Hobbyist
Join Date: Sep 2005
Posts: 266
Rep Power: 4
![]() |
I think the question is more concerned with the specifics of how the second template parameter is deduced.
|
|
|
|
|
|
#4 | |
|
Hobbyist
Join Date: Sep 2005
Posts: 266
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
All template parameters are "deduced" at compile time.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|