Questions tagged [inline]

Use this tag for questions specifically about the effects of the inline keyword, together with the appropriate language tag.

Inline, or inline expansion, is a programming language optimization that inserts the complete body of the function in every place that the function is called. Depending on the programming language, this may be implemented by the compiler, manually or by a keyword.

Historically, in the C and C++ programming languages, an inline function is a function upon which the compiler has been requested to perform inline expansion. In other words, the programmer has requested that the compiler insert the complete body of the function in every place that the function is called, rather than generating code to call the function in the one place it is defined. However, modern compilers usually use their own heuristics and ignore the request. Thus, the inline keyword is now mostly used for its effects on the One Definition Rule.

Inline expansion is used to eliminate the time overhead when a function is called. It is typically used for functions that execute frequently. It also has a space benefit for very small functions, and is an enabling transformation for other optimizations.

3753 questions
21
votes
3 answers

Inline method: inside vs outside class definition

If you have a method and you want to give the compiler a hint that it is a good idea to inline it, you currently have two solutions. The first one is to define the methods when you declare your class: class Vector { private: double* data_; …
InsideLoop
  • 6,063
  • 2
  • 28
  • 55
21
votes
3 answers

Template definitions outside class body

Is it O.K. to define virtual function of class template outside its body? Virtual function can not be inlined, but to avoid multiple definitions in compilation units they shall be marked inline (assuming that template headers will be included in…
mip
  • 8,355
  • 6
  • 53
  • 72
20
votes
4 answers

If inlining is optional, why does removing 'inline' cause linker errors?

I have a class that had an inline member, but I later decided that I wanted to remove the implementation from the headers so I moved the members body of the functions out to a cpp file. At first I just left the inlined signature in the header file…
Robert Gould
  • 68,773
  • 61
  • 187
  • 272
20
votes
2 answers

Using inline XSLT for an XML file

I have a XML file and an external XSLT file. Currently, within my XML I refer to an external XSLT link using an href:
Akshay
  • 2,417
  • 7
  • 25
  • 21
20
votes
3 answers

Cython inline function with numpy array as parameter

Consider code like this: import numpy as np cimport numpy as np cdef inline inc(np.ndarray[np.int32_t] arr, int i): arr[i]+= 1 def test1(np.ndarray[np.int32_t] arr): cdef int i for i in xrange(len(arr)): inc(arr, i) def…
Maxim
  • 463
  • 2
  • 5
  • 12
20
votes
3 answers

SQL Server: Select in vs or?

Which is faster? SELECT UserName FROM dbo.UserTable WHERE UserID in (1,3,4) SELECT UserName FROM dbo.UserTable WHERE UserID = 1 OR UserID = 3 OR UserID = 4
ctrlShiftBryan
  • 27,092
  • 26
  • 73
  • 78
20
votes
2 answers

why does F# inline cause 11x performance improvement

I am working on some heavy cpu bound problem. I see a big performance improvement when I use the inline keyword. I create a dictionary from the standard .net library passing in a custom key Comparer see code and timing results…
isaiah_p
  • 325
  • 1
  • 8
20
votes
2 answers

Margin top in inline element

My question is pretty simple: Why is the margin top ignored for inline elements in firefox? Does anyone know?
Tony
  • 10,088
  • 20
  • 85
  • 139
19
votes
2 answers

Can you inline static member functions?

I have a static member function which is merely syntactic sugar for me and I would like its body to appear in place of going through the motions of passing parameters to it. Will inline static foo(int a) {return a & 0x00000040;} be inlined just as…
John
  • 6,433
  • 7
  • 47
  • 82
19
votes
4 answers

Override CSS text-transform

I am using the following CSS which transforms all text to uppercase: .taxtabs { font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif; font-size: .8em; width: inherit; text-align:center; text-transform: uppercase; border-collapse:…
DanielAttard
  • 3,467
  • 9
  • 55
  • 104
19
votes
4 answers

putting function definitions in header files

If you want to put function definitions in header files, it appears there are three different solutions: mark the function as inline mark the function as static put the function in an anonymous namespace (Until recently, I wasn't even aware of…
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
19
votes
3 answers

How to vertically align inline elements

I have this anchor tag that has text between to be vertically align text. I'm using this css attribute vertical-align: middle. Nothing happens tho.
dave
  • 14,991
  • 26
  • 76
  • 110
19
votes
2 answers

How do I indent the first line of a paragraph using HTML inline styling?

I'm creating an HTML email and I do not want to use CSS styling in the head (for cross platform compatibility reasons). I need to set an indention for the first line of the paragraph using inline styling only. How would I do that?
jarrodwhitley
  • 826
  • 10
  • 29
19
votes
4 answers

Calling std::nth_element() function extremely frequently

I did not find this specific topic anywhere... I am calling the nth_element() algorithm about 400,000 times per second on different data in a std::vector of 23 integers, more precise "unsigned short" values. I want to improve computation speed and…
karsten
  • 639
  • 5
  • 13
19
votes
6 answers

Do inline functions have addresses?

In section 7.1.1 of the book "The C++ Programming Language" the author states: "inline function still has a unique address and so do the static variables of an inline function" I am confused. If I have an inline function then it can't have address.…
Xolve
  • 22,298
  • 21
  • 77
  • 125