0

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

Leonid
  • 22,360
  • 25
  • 67
  • 91
  • 2
    Why 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
  • 3
    Generally, "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 Answers4

4
  • 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

Armen Tsirunyan
  • 130,161
  • 59
  • 324
  • 434
1

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.

Marcelo Cantos
  • 181,030
  • 38
  • 327
  • 365
0

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.

Johan Kotlinski
  • 25,185
  • 9
  • 78
  • 101
0

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

Community
  • 1
  • 1
Pascal Cuoq
  • 79,187
  • 7
  • 161
  • 281