In C++ what does it mean that template and inline are orthogonal
?

- 22,360
- 25
- 67
- 91
-
2Why don't you ask the person who said it (sbi)? http://stackoverflow.com/questions/4077609/overloading-output-stream-operator-for-vectort/4077666#4077666 – Steve Jessop Nov 02 '10 at 12:49
-
3Generally, "orthogonal" is used informally to mean "independent, unrelated, irrelevant to". Derived ultimately from the fact that an orthogonal set of vectors is commonly seen as a basis for a vector space, and "linearly independent", while a more accurate metaphor (since orthogonality is a sufficient but not necessary condition for linear independence), is a bit of a mouthful. – Steve Jessop Nov 02 '10 at 12:51
-
You haven't even quoted him accurately. "templatizing" != template, and "inlining" != inline. – Johannes Schaub - litb Nov 02 '10 at 22:28
-
What I meant was *template* and *inline* keywords. Perhaps should have made it more clear or better never asked the question in the first place. However, the thread turned out to carry some information. Feel free to edit of you think it is not clear. – Leonid Nov 03 '10 at 08:58
4 Answers
If two things are "orthogonal" it means they are independent. In this case, it means that a template can be inline, a template can be noninline, a nontemplate can be noninline, and a nontemplate can be inline.
I think the question arises because there is some surface similarity between the two in that both should be present in the translation unit in which they are used, in other words, their definitions (bodies, implementatinos) should be provided in the .h file. However template and inline are indeed orthogonal as is seen from the first paragraph. HTH

- 130,161
- 59
- 324
- 434
-
Also note that in algebra orthogonal means (informally) perpendicular, linearly independent :) – Armen Tsirunyan Nov 02 '10 at 12:57
-
I would say that perpendicular is a special case (in a special context) of orthogonality. – Cedric H. Nov 02 '10 at 13:32
-
It means that something can be a template or not without reference to whether it is inline or not. They are different concepts with different purposes.
I think the term is misleading, however, since the two concepts do interact in non-trivial ways. For instance, a non-inline function generally can't be declared in a .h file, but it can and usually must if it is a function template. So template
and inline
are mostly but not entirely orthogonal.

- 181,030
- 38
- 327
- 365
Loosely speaking, it means that they don't change each others behavior. E.g. inline means the same thing regardless whether it's used with template functions or normal functions.

- 25,185
- 9
- 78
- 101
You are looking (in part) for a definition of "orthogonal" in computer science, that you can find in the answers here.

- 1
- 1

- 79,187
- 7
- 161
- 281